【初心者】Java質問・相談スレ�F【大歓迎】
■ このスレッドは過去ログ倉庫に格納されています
0115110
NGNGpublic int val;public volatile boolean inited = false;
public void run(){
synchronized(this){
inited =true;
try{
while(true){
wait();System.out.println(val);
}
}
catch(InterruptedException e){}
}
}
}
public class Test {
public static void main(String args[]){
Thread t = new Test2();
t.start();
while(!t.inited)Thread.yield();
for(int i = 0; i < 3 ; i++){
syncrhonized(t){t.val=i;t.notify();}
}
t.interrupt();
}
}
■ このスレッドは過去ログ倉庫に格納されています