Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is Timer and TimerTask in Java – Tutorial Example

What Is Timer And TimerTask In Java – Tutorial Example
Timer in Java is a utility class that is used to schedule tasks for both one time and repeated execution. Timer is similar to the alarm facility many people use in mobile phones. Just like you can have one time alarm or repeated alarm, You can use java.util.Timer to schedule a time task or repeated task. In fact, we can implement a Reminder utility using Timer in Java and that's what we are going to see in this example of Timer in Java. Two classes java.util.Timer and java.util.TimerTask is used to schedule jobs in Java and forms Timer API. The TimerTask is an actual task that is executed by Timer. Similar to Thread in JavaTimerTask also implements the Runnable interface and overrides run method to specify a task details. 


This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here

Share the post

What is Timer and TimerTask in Java – Tutorial Example

×

Subscribe to Javarevisited: Blog About Java Programmin

Get updates delivered right to your inbox!

Thank you for your subscription

×