Reputation: 163
I need help / advice for a problem..I created a service
and in this I need to run an action when two integers
or two strings
are equals
..what is the best way?
I tried with a timer:
timer.schedule(new mainTask(), mydate.equals(date));
private class mainTask extends TimerTask
{
public void run()
{
}
}
but that does not accept boolean in the when
parameter..
What can I use to get what i want?
ps: my parameters are taken from a database
Thanks in advance!
Upvotes: 0
Views: 236
Reputation: 11053
Not sure exactly what you mean but if the deamon should be dependant on the strings and integers why don't you just define a method like this:
private boolean myDaemon(String s1, String s2, int i1, int i2) {
return ( s1.equals(s2) || ( i1 == i2));
}
and use this as your parameter ?
However, if you want to schedule
the timer only if this condition applies then you have to write something like:
if (myDaemon(s1,s2,i1,i2)) scheduleMytimer();
ps the second parameter to Timer is not a condition but the DeamonFlag!
Upvotes: 1