shunping commented on code in PR #30278:
URL: https://github.com/apache/beam/pull/30278#discussion_r1485463657


##########
sdks/java/core/src/test/java/org/apache/beam/sdk/fn/data/BeamFnDataInboundObserverTest.java:
##########
@@ -165,6 +171,11 @@ public void 
testCloseVisibleToAwaitCompletionCallerAndProducer() throws Exceptio
     Future<?> future2 =
         executor.submit(
             () -> {
+              synchronized (isReady) {

Review Comment:
   Using synchronized block on isReady works here. I don't see there is a 
deadlock.
   
   (1) If it runs the first synchronized block first, then it will call 
notify() and isReady is set to true. Then when the second synchronized block is 
executed, it will not reach the wait() call because isReady is true.
   
   (2) If it runs the second synchronized block first, then it will wait() and 
give up the lock, while in the first synchronized block, it will pick up the 
lock, set isReady to true, and then call notify(). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to