-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ThreadSamples; | ||
|
||
public class ThreadSamples { | ||
public static void main(String[] args) { | ||
System.out.println("==> Thread Samples"); | ||
|
||
TimerTaskSample timerTaskSample = new TimerTaskSample(); | ||
timerTaskSample.SampleOne(); | ||
timerTaskSample.SampleTwo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package ThreadSamples; | ||
|
||
import java.util.Calendar; | ||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
|
||
public class TimerTaskSample { | ||
public void SampleOne() { | ||
System.out.println("\n===> Timer Task Sample One"); | ||
|
||
Timer timer = new Timer(); | ||
TimerTask task = new TimerTask() { | ||
@Override | ||
public void run() { | ||
System.out.println("Task is complete (Sample One)!"); | ||
} | ||
}; | ||
timer.schedule(task, 3000); | ||
} | ||
|
||
public void SampleTwo() { | ||
System.out.println("\n===> Timer Task Sample Two"); | ||
|
||
Timer timer = new Timer(); | ||
TimerTask task = new TimerTask() { | ||
@Override | ||
public void run() { | ||
System.out.println("Task is complete!"); | ||
} | ||
}; | ||
|
||
Calendar date = Calendar.getInstance(); | ||
date.set(Calendar.YEAR, 2024); | ||
date.set(Calendar.MONDAY, Calendar.DECEMBER); | ||
date.set(Calendar.DAY_OF_MONTH, 22); | ||
date.set(Calendar.HOUR_OF_DAY, 0); | ||
date.set(Calendar.SECOND, 0); | ||
date.set(Calendar.MILLISECOND, 0); | ||
timer.schedule(task, date.getTime()); | ||
} | ||
} |