问题描述:
请java高手帮我注释或者解释一下这个例子?求大神帮助
请java高手帮我注释或者解释一下这个例子?这是线程组的一个例子看不懂,谢谢帮助;public class Grp implements Runnable{public void run(){for(;;){System.out.println("thread: " + Thread.currentThread().getName());try{Thread.sleep(300);}catch(InterruptedException e){}}}public static void main(String[] args){ThreadGroup g = new ThreadGroup("My Group");Runnable r = new Grp();Thread t = new Thread(g,r);t.start();t = new Thread(g,r);t.start();for(;;){try{Thread.sleep(5000);}catch(InterruptedException e){}g.suspend();System.out.println("thread " + Thread.currentThread().getName());try{Thread.sleep(5000);}catch(InterruptedException e){}g.resume();}} }
请java高手帮我注释或者解释一下这个例子?这是线程组的一个例子看不懂,谢谢帮助;public class Grp implements Runnable{public void run(){for(;;){System.out.println("thread: " + Thread.currentThread().getName());try{Thread.sleep(300);}catch(InterruptedException e){}}}public static void main(String[] args){ThreadGroup g = new ThreadGroup("My Group");Runnable r = new Grp();Thread t = new Thread(g,r);t.start();t = new Thread(g,r);t.start();for(;;){try{Thread.sleep(5000);}catch(InterruptedException e){}g.suspend();System.out.println("thread " + Thread.currentThread().getName());try{Thread.sleep(5000);}catch(InterruptedException e){}g.resume();}} }
问题解答:
我来补答展开全文阅读