两个线程A和B, A打印1, 3, ..., 99, B打印2, 4, ..., 100, 要求A和B严格交替打印(Java实现)
第一种实现:public class ThreadAB1 { Thread A = new Thread(new Runnable() { public void run() { for (int i = 1; i < 100; i += 2) { print("A " + i); } } }); Thread B = new Thread(new Runna
原创
2013-04-02 23:38:49 ·
2266 阅读 ·
1 评论