创建两个线程 一个目标对象 怎么分别打印两次循环? 大神勿笑
class test implements Runnable
{
//private static int b=80;synchronized
public void run()
{
for (int i=0;i<100 ;i++ )
{
System.out.println(Thread.currentThread().getName()+"......."+"第"+i+"个");
}
}
}
class testDemo
{
public static void main(String[] args)
{
test v = new test();
Thread t1 = new Thread(v);
Thread t2 = new Thread(v);
t1.start();
t2.start();
//System.out.println("Hello World!");
}
}
|