How do I make a timer run in the background?
I can get my timer to stop the thread and wait for the timer to finish. This is not what I want to d though. I want have the timer going and still be able to use the other buttons in my program. How can I do this?
Code:
int delay = 100; //milliseconds
Timer t = new Timer(delay, taskPerformer);
t.start();
System.out.println( t.isRunning() );
System.out.println( t.getDelay() );
// wait 10 seconds before going on.
try {
Thread.sleep(10000);
}
catch (Exception ea) {}
t.stop();
ActionListener taskPerformer = new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
System.out.println( "test" );
labelHomeNumber[0].setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
labelHomeName[0].setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
}
};
Please help.