就拿这个程序为例。public class GetCurrentThread implements Runnable {Thread th;public GetCurrentThread(String threadName) {th = new Thread(this,threadName); //<----DOUBTSystem.out.println("get threadname "+th.getName());th.start();}public void run() {System.out.println(th.getName()+" is starting.....");System.out.println("Current thread name : " + Thread.currentThread().getName());}public static void main(String args[]) {System.out.println("Current thread name : " + Thread.currentThread().getName());new GetCurrentThread("1st Thread");//new GetCurrentThread("2nd Thread");}}
添加回答
举报
0/150
提交
取消