Here is the code:
timer.schedule(new TimerTask()
{
public void run()
{
synchronized(this)
{
try
{
// System.out.println(" ITERATION = ");
pachubeCLI.update(78164);
}
catch (PachubeException e)
{
// If an exception occurs it will print the error message from the
// failed HTTP command
System.err.println(e.errorMessage);
}
catch (IOException e)
{
System.err.println(e);
}
}
}
}, 0, 5*1000);
I can tell that the code is basically being used to schedule an operation using an object of the Timer
class. The parameters passed to the schedule
method , according to eclipse , are (TimerTask task,long delay, long period)
. But looking at this code , an entire block of code is being passed as the first parameter instead of a reference to the TimerTask
class. I've never seen such a method before. What exactly is happening here?
Some background: The schedule
method of the Timer
object is being used to update a feed on Xively(previously COSM(previously pachube)) periodically.
Also I don't know which tag describes what is happening here.If you do please add it or drop in a comment.