forked from JFulgoni/Java-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.java
More file actions
46 lines (40 loc) · 985 Bytes
/
Copy pathTask.java
File metadata and controls
46 lines (40 loc) · 985 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
package john_test;
public class Task implements Runnable, java.io.Serializable{
private static volatile int TASKNUM = 10;
//private String threadName;
private char killKey;
private boolean threadInterrupt;
private int displayNum;
public Task(){
//this.threadName = threadName;
threadInterrupt = false;
displayNum = 0;
}
@Override
public void run() {
int derp;
try{
while(TASKNUM > 0){
derp = TASKNUM;
--TASKNUM;
System.out.println("Inside " + Thread.currentThread().getName() + ": " + TASKNUM);
Thread.sleep(2000L);
}
}
catch (InterruptedException iex){}
// try{
// int derp = 0;
// //System.out.println("Inside " + threadName);
// while(!threadInterrupt){
// System.out.println(++derp);
// threadInterrupt = shouldStop();
// Thread.sleep(2000L);
// }
// }
// catch (InterruptedException iex){}
// //System.out.println("Exiting " + threadName);
}
public boolean shouldStop(){
return false;
}
}