BruceEckel / TIJ4-code

Example code for the book "Thinking in Java, 4th Edition"
Other
836 stars 469 forks source link

"concurrency/ExplicitCriticalSection.java" not accurate #4

Open caob1234 opened 4 years ago

caob1234 commented 4 years ago

ExplicitPairManager1 method could't use synchronized keywords

jhwsx commented 4 years ago

Yes,they are ill codes.

dawxy commented 4 years ago

ExplicitPairManager2. increment() and PairChecker.run() have data race. ExplicitPairManager2.lock and PairManager.getPair() are not the same lock, The synchronized lock used by PairManager.getPair () is the ExplicitPairManager2 object lock.