【发布时间】:2015-01-12 11:52:59
【问题描述】:
我有 2 个线程,他们想以这种方式执行一些过程
Public Class MyThread implements Runnable{
in public void run(){
for(int i=0;i<=20;i++)
//t1 thread will come & print 1 to 10 numbers only
//t2 thread will come & print next numbers i.e 11 to 20 only.
}
}
public Class MainClass{
public static void main(String arg[]){
MyThread obj=new MyThread();
Thread t1=new Thread(obj);
Thread t2=new Thread(obj);
t1.start();
t2.start();
}
}
如何限制我的线程只打印具有 run() 方法中提到的条件的数字?
【问题讨论】:
标签: java multithreading