- private int turn=0; //FINAL 对STATIC变量有何影响
-
- public synchronized void print1() {
-
- if ( turn%3!=0)
- try
- {this.wait();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- for (int i = 0; i < 3; i++)
- System.out.println("A");
- System.out.println();
-
- turn ++;
- this.notify();
-
- }
- public synchronized void print2() {
-
- if ( turn%3!=1)
- try
- {this.wait();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- for (int i = 0; i < 3; i++)
- System.out.println("B");
- System.out.println();
-
- turn++;
- this.notify();
- }
复制代码 请问下.notify();方法运行过后,是从哪条语句开始运行? |
|