You need to start a thread for every timer action. Calling the run run () method does not start the thread.
public void actionPerformed(ActionEvent e)
{
Downloader t = new Downloader();
t.start();
}
It might be better to use an anonymous class for actionlistener. Sorry my java syntax, but I have not tested it ...
new Timer(500,
new ActionListener(){
public void actionPerformed(ActionEvent e)
{
Downloader t = new Downloader();
t.start();
}
}).start();
Or without a timer ...
public static void gogogo()
{
t= new Downloader();
t.start();
}
public void run()
{
while(true){
doStuff();
Thread.sleep(500);
}
}
source
share