- //线程1
- boolean stop = false;
- while(!stop){
- doSomething();
- }
-
-
- //线程2
- stop = true;
- int a = 0;
- bool flag = false;
-
- public void write(){
- a = 2; //1
- flag = true; //2
- }
-
- public void multiply(){
- if(flag){ //3
- int ret = a * a; //4
- }
- }