Why I am not able to display image using swing worker?

Posted by Vimal Basdeo on Stack Overflow See other posts from Stack Overflow or by Vimal Basdeo
Published on 2010-12-28T06:44:56Z Indexed on 2010/12/28 6:54 UTC
Read the original article Hit count: 502

Filed under:
|
|

I was trying some codes to implement a scheduled task and came up with these codes .

import java.util.*;

class Task extends TimerTask {

int count = 1;

// run is a abstract method that defines task performed at scheduled time.
public void run() {
    System.out.println(count+" : Mahendra Singh");
    count++;
}

}

class TaskScheduling {

public static void main(String[] args) { Timer timer = new Timer();

   // Schedule to run after every 3 second(3000 millisecond)
   timer.schedule( new Task(), 3000);   

} }

My output :

1 : Mahendra Singh

I expected the compiler to print a series of Mahendra Singh at periodic interval of 3 s but despite waiting for around 15 minutes, I get only one output...How do I solve this out?

© Stack Overflow or respective owner

Related posts about java

Related posts about timer