2021
06-12
06-12
Java多线程之线程同步
volatile先看个例子classTest{//定义一个全局变量privatebooleanisRun=true;//从主线程调用发起publicvoidprocess(){test();try{Thread.sleep(2000);}catch(InterruptedExceptione){e.printStackTrace();}stop();}//启动一个子线程循环读取isRunprivatevoidtest(){newThread(newRunnable(){...
继续阅读 >