50,527
社区成员
发帖
与我相关
我的任务
分享
List listObj=new ArrayList();
for(int i=0;i<30;i++){
A a=new A();
Thread thread=new Thread(a);
listObj.add(a);
thread.start();
}
class A implements Runnable{
public Map map;
public boolean isBusy=false;
public void run(){
while(true){
if(map!=null){
isBusy=true;
//逻辑操作,不影响map,只读
map=null;
isBusy=false;
}else{
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}