这段代码是按书上打的,但是我调试不出来,请大家帮我看看,是关于多线程的,顺便问问大家在工作中多线程用的多么,学什么实用点啊??
代码如下:(文件名我取的 ThreadTest.java)
class CountingThread extends Thread
{
public void run()
{
System.out.println("Thread started:"+ this);
for(int i=0; i<9; i++)
System.out.print("i="+(i+1)+"\t");
System.out.println("Thread stopped:"+ this);
}
}
public class ThreadTest
{
public static void main(String args[])
{
System.out.println("Statring ThreadTest");
CountingThread thread1=new CountingThread();
thread1.start();
CountingThread thread2=new CountingThread();
thread2.start();
CountingThread thread3=new CountingThread();
thread3.start();
System.out.println("ThreadTest is done.");
}
}
谢谢指教!!
代码如下:(文件名我取的 ThreadTest.java)
class CountingThread extends Thread
{
public void run()
{
System.out.println("Thread started:"+ this);
for(int i=0; i<9; i++)
System.out.print("i="+(i+1)+"\t");
System.out.println("Thread stopped:"+ this);
}
}
public class ThreadTest
{
public static void main(String args[])
{
System.out.println("Statring ThreadTest");
CountingThread thread1=new CountingThread();
thread1.start();
CountingThread thread2=new CountingThread();
thread2.start();
CountingThread thread3=new CountingThread();
thread3.start();
System.out.println("ThreadTest is done.");
}
}
谢谢指教!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货