forked from vipstone/java-core-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyThread.java
More file actions
34 lines (30 loc) · 835 Bytes
/
Copy pathMyThread.java
File metadata and controls
34 lines (30 loc) · 835 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
package example;
//public class MyThread implements Runnable {
// @Override
// public void run() {
// System.out.println(Thread.currentThread().getName());
// }
//}
public class MyThread extends Thread{
@Override
public void run() {
synchronized (MyThread.class){
try {
MyThread.class.wait(1000);
System.out.println(Thread.currentThread().getName());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
//import java.util.concurrent.Callable;
//
//public class MyThread implements Callable<String> {
//
// @Override
// public String call() throws Exception {
// System.out.println(Thread.currentThread().getName());
// return Thread.currentThread().getName();
// }
//}