Abhijeetmishr commented on issue #19671: URL: https://github.com/apache/pulsar/issues/19671#issuecomment-1509929746
@tisonkun I could have provided brief introduction beforehand only sorry for that. > I think making this AtomicBoolean seek asynchronous will help us. **Problem :-** > Suppose you have a shared AtomicBoolean variable named flag and two threads, Thread A and Thread B. Thread A sets the value of flag to true, and Thread B reads the value of flag. If Thread B reads the value of flag before Thread A sets it to true, then Thread B might enter an infinite loop because it assumes that the value of flag is false. **Solution :-** > we need to use a synchronization mechanism, such as an asynchronous behavior, to ensure that the value of flag is set before it is read. > we use a CompletableFuture or a Future object to run the task asynchronously. -- 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]
