|
@@ -30,39 +30,4 @@ public class DateExtUtil {
|
|
|
return gc.getTime();
|
|
|
}
|
|
|
|
|
|
- public void test1() throws InterruptedException {
|
|
|
- synchronized (this){
|
|
|
- System.out.println("test1 start");
|
|
|
- Thread.sleep(5000);
|
|
|
- System.out.println("test1 end");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void test2() throws InterruptedException {
|
|
|
- synchronized (this){
|
|
|
- System.out.println("test2 start");
|
|
|
- Thread.sleep(5000);
|
|
|
- System.out.println("test2 end");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- DateExtUtil dateExtUtil = new DateExtUtil();
|
|
|
- new Thread(()->{
|
|
|
- try {
|
|
|
- dateExtUtil.test1();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }).start();
|
|
|
-
|
|
|
- new Thread(()->{
|
|
|
- try {
|
|
|
- dateExtUtil.test2();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }).start();
|
|
|
- }
|
|
|
-
|
|
|
}
|