Click here to watch on Youtube: 
https://www.youtube.com/watch?v=uz2g9LpumiY&list=UUhwKlOVR041tngjerWxVccw
ReminderTimerTask.java
TimerDemo.java
Output:
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/TimerDemo_thread_name.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/TimerDemo_thread_name
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/2db5cd1f4e7d5ab55ad7af886d6164700143c614/Java_2019/TimerDemo_thread_name/?at=master
See also:
All JavaEE Videos Playlist 
All JavaEE Videos 
All JAVA EE Links 
Spring Tutorial 
Servlets Tutorial 
All Design Patterns Links 
JDBC Tutorial 
Java Collection Framework Tutorial 
JAVA Tutorial 
Kids Tutorial 
Cooking Tutorial 
https://www.youtube.com/watch?v=uz2g9LpumiY&list=UUhwKlOVR041tngjerWxVccw
ReminderTimerTask.java
import java.util.TimerTask;
public class ReminderTimerTask extends TimerTask
{
public void run()
{
System.out.println("Wake up...");
}
}
public class ReminderTimerTask extends TimerTask
{
public void run()
{
System.out.println("Wake up...");
}
}
TimerDemo.java
import java.util.Timer;
import java.util.TimerTask;
public class TimerDemo
{
public static void main(String[] args) throws InterruptedException
{
/*
*
* Creates a new timer whose associated thread has the
* specified name. The associated thread does not run as a
* daemon.
*
* Parameters:
*
* name - the name of the associated thread
*/
Timer timer = new Timer("Reminder Timer");
TimerTask reminderTimerTask = new ReminderTimerTask();
timer.schedule(reminderTimerTask, 5000, 2000);
System.out.println("Timer has schedule the reminderTimerTask...");
}
}
import java.util.TimerTask;
public class TimerDemo
{
public static void main(String[] args) throws InterruptedException
{
/*
*
* Creates a new timer whose associated thread has the
* specified name. The associated thread does not run as a
* daemon.
*
* Parameters:
*
* name - the name of the associated thread
*/
Timer timer = new Timer("Reminder Timer");
TimerTask reminderTimerTask = new ReminderTimerTask();
timer.schedule(reminderTimerTask, 5000, 2000);
System.out.println("Timer has schedule the reminderTimerTask...");
}
}
Output:
Timer has schedule the reminderTimerTask...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Wake up...
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/TimerDemo_thread_name.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/TimerDemo_thread_name
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/2db5cd1f4e7d5ab55ad7af886d6164700143c614/Java_2019/TimerDemo_thread_name/?at=master
See also:
 


 
No comments:
Post a Comment