()
| 10 | } |
| 11 | |
| 12 | @Override |
| 13 | public void run() { |
| 14 | while (true) { |
| 15 | synchronized (s) { |
| 16 | if (s.flag) { |
| 17 | // ��ͱ�ʾ������ |
| 18 | try { |
| 19 | s.wait(); // t1�͵ȴ��� |
| 20 | } catch (InterruptedException e) { |
| 21 | e.printStackTrace(); |
| 22 | }// ��������ȴ� |
| 23 | } |
| 24 | |
| 25 | if (x % 2 == 0) { |
| 26 | s.name = "����ϼ"; |
| 27 | s.age = 28; |
| 28 | } else { |
| 29 | s.name = "����"; |
| 30 | s.age = 31; |
| 31 | } |
| 32 | x++; // x=1,x=2 |
| 33 | |
| 34 | // ������ʾ |
| 35 | s.flag = true; |
| 36 | s.notify(); // ���ѵȴ����̣߳������������߳��ܹ�������ȡCPU��ִ��Ȩ |
| 37 | } |
| 38 | // t1,t2�� |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | } |
nothing calls this directly
no outgoing calls
no test coverage detected