看代码 public class TestSleep { public static void main(String args[]) throws InterruptedException{ Thread t1 = new CountThread(); t1.start(); Thread.sleep(6000); System.out.println("即将中断阻塞"); t1.interrupt(); } } public class CountThread extends Th
题目如下: 子线程循环10次,接着主线程循环100,接着又回到子线程循环10次, 接着再回到主线程又循环100,如此循环50次 思路如下: 子线程语主线程为互斥,可用SYNCHRONIZED.很容易想到如下代码 package concurrent; public class theFirstIdea{ /** * @param args */ public static void main(String[] args) { new Thread(//子线程 new Runnable(){ pu