怎么判断什么样的线程才是守护线程
classThreadDemoimplementsRunnable{intage=0;publicsynchronizedvoidrun(){for(inti=0;i<1...
class ThreadDemo implements Runnable{
int age=0;
public synchronized void run(){
for(int i=0;i<100;i++){
System.out.println("age="+(age++));
}
}
}
下列构造线程对象的方式中,两个线程共用一个age数据的是:
A.
ThreadDemo r1=new ThreadDemo();
ThreadDemo r2=new ThreadDemo();
B.
Thread t1=new Thread();
Thread t2=new Thread();
C.
ThreadDemo r1=new ThreadDemo();
Thread t1=new Thread(r1);
Thread t2=new Thread(r1);
D.
ThreadDemo r1=new ThreadDemo();
ThreadDemo r2=new ThreadDemo();
Thread t1=new Thread(r1); 展开
int age=0;
public synchronized void run(){
for(int i=0;i<100;i++){
System.out.println("age="+(age++));
}
}
}
下列构造线程对象的方式中,两个线程共用一个age数据的是:
A.
ThreadDemo r1=new ThreadDemo();
ThreadDemo r2=new ThreadDemo();
B.
Thread t1=new Thread();
Thread t2=new Thread();
C.
ThreadDemo r1=new ThreadDemo();
Thread t1=new Thread(r1);
Thread t2=new Thread(r1);
D.
ThreadDemo r1=new ThreadDemo();
ThreadDemo r2=new ThreadDemo();
Thread t1=new Thread(r1); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询