-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavalab19.java
More file actions
29 lines (27 loc) · 750 Bytes
/
Copy pathjavalab19.java
File metadata and controls
29 lines (27 loc) · 750 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
public class javalab19 {
public static void main(String[] args) {
Thread csThread = new NamedThread("CSthread");
Thread itThread = new NamedThread("ITthread");
csThread.start();
itThread.start();
}
}
class NamedThread extends Thread{
private int count = 0;
public NamedThread(String name){
super(name);
}
@Override
public void run(){
while(count < 10){
try{
Thread.sleep(7000);
count++;
System.out.println(getName() + " execution count: " + count);
}
catch(InterruptedException e){
System.out.println(getName() + " was interrupted.");
}
}
}
}