MCPcopy Create free account
hub / github.com/crossoverJie/JCSprout / OuNum

Class OuNum

src/main/java/com/crossoverjie/actual/TwoThread.java:47–73  ·  view source on GitHub ↗

偶数线程

Source from the content-addressed store, hash-verified

45 * 偶数线程
46 */
47 public static class OuNum implements Runnable {
48
49 private TwoThread number;
50
51 public OuNum(TwoThread number) {
52 this.number = number;
53 }
54
55 @Override
56 public void run() {
57 while (number.start <= 1000) {
58
59 if (number.flag) {
60 try {
61 LOCK.lock();
62 System.out.println(Thread.currentThread().getName() + "+-+" + number.start);
63 number.start++;
64 number.flag = false;
65
66
67 } finally {
68 LOCK.unlock();
69 }
70 }
71 }
72 }
73 }
74
75 /**
76 * 奇数线程

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected