Skip to content

Commit a121c2d

Browse files
committed
Key comments.
1 parent f6f787a commit a121c2d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Chapter10/PC2.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ void setSharedChar(char c){
8282
}catch(Exception e){
8383
e.printStackTrace();
8484
}finally{
85-
System.out.println("Before setSharedChar unlock: " + lock + lock.getHoldCount());
85+
System.out.println("Before setSharedChar unlock: " + lock + lock.getHoldCount()); // count 2
8686
lock.unlock();
87-
System.out.println("After setSharedChar unlock: " + lock + lock.getHoldCount());
87+
System.out.println("After setSharedChar unlock: " + lock + lock.getHoldCount()); // count 1
8888
// The lock is still locked by ProducerThread because of holder count not be zero.
8989
}
9090
}
@@ -149,7 +149,7 @@ public void run(){
149149
}catch(InterruptedException ie){
150150
ie.printStackTrace();
151151
}
152-
System.out.println("Consumer afterGetChar: " + lock + lock.getHoldCount());
152+
System.out.println("Consumer afterGetChar: " + lock + lock.getHoldCount()); // count 1
153153

154154
System.out.println(ch + " consumed by consumer.");
155155
lock.unlock();

0 commit comments

Comments
 (0)