File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ();
You can’t perform that action at this time.
0 commit comments