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

Class JiNum

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

奇数线程

Source from the content-addressed store, hash-verified

76 * 奇数线程
77 */
78 public static class JiNum implements Runnable {
79
80 private TwoThread number;
81
82 public JiNum(TwoThread number) {
83 this.number = number;
84 }
85
86 @Override
87 public void run() {
88 while (number.start <= 1000) {
89
90 if (!number.flag) {
91 try {
92 LOCK.lock();
93 System.out.println(Thread.currentThread().getName() + "+-+" + number.start);
94 number.start++;
95 number.flag = true;
96
97
98 } finally {
99 LOCK.unlock();
100 }
101 }
102 }
103 }
104 }
105}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected