Commit de5594c78598426be3ae155f0525a22c01bbc4c0

Authored by maliang
1 parent 70a2c92ff2
Exists in master

测试提交。

Showing 1 changed file with 11 additions and 38 deletions

parent/center.manager/src/test/java/center/manager/test/user/DeadLockTest.java View file @ de5594c
1 1 package center.manager.test.user;
2 2  
3   -public class DeadLockTest implements Runnable {
4   - private int flag;
5   - static Object o1 = new Object(), o2 = new Object(); // 静态的对象,被DeadLockTest的所有实例对象所公用
  3 +public class DeadLockTest {
6 4  
7   - public void run() {
8   -
9   - System.out.println(flag);
10   - if (flag == 0) {
11   - synchronized (o1) {
12   - try {
13   - Thread.sleep(500);
14   - } catch (Exception e) {
15   - e.printStackTrace();
16   - }
17   - synchronized (o2) {
18   - }
19   - }
20   - }
21   - if (flag == 1) {
22   - synchronized (o2) {
23   - try {
24   - Thread.sleep(500);
25   - } catch (Exception e) {
26   - e.printStackTrace();
27   - }
28   - synchronized (o1) {
29   - }
30   - }
31   - }
  5 + public static void main(String[] args) {
  6 + System.out.println(63 >> 3);
  7 + System.out.println(62 >> 3);
  8 + System.out.println(60 >> 3);
  9 + System.out.println(56 >> 3);
  10 + System.out.println(48 >> 3);
  11 + System.out.println(32 >> 3);
  12 + System.out.println(0 >> 3);
32 13 }
33 14  
34   - public static void main(String[] args) {
35   - /*
36   - * DeadLockTest test1 = new DeadLockTest(); DeadLockTest test2 = new
37   - * DeadLockTest(); test1.flag = 1; test2.flag = 0; Thread thread1 = new
38   - * Thread(test1); Thread thread2 = new Thread(test2); thread1.start();
39   - * thread2.start();
40   - *
41   - */
42   - System.out.println(18 ^ 7);
43   -
  15 + private static void printInfo(int num) {
  16 + System.out.println(Integer.toBinaryString(num));
44 17 }
45 18 }