-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimerExceptionTest.java
More file actions
50 lines (37 loc) · 903 Bytes
/
TimerExceptionTest.java
File metadata and controls
50 lines (37 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package moreAboutJava;
import java.util.Timer;
import java.util.TimerTask;
public class TimerExceptionTest {
private static Timer timer = new Timer();
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
launchTimer();
Thread.sleep(5000);
addTimer();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static void addTimer() {
// TODO Auto-generated method stub
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("add timer");
}
}, 1000, 1000);
}
private static void launchTimer() {
// TODO Auto-generated method stub
timer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
throw new RuntimeException();
}
}, 3000, 500);
}
}