133tosakarin commented on PR #1168:
URL: https://github.com/apache/ratis/pull/1168#issuecomment-2421229837
> * Version 1
>
> ```java
> synchronized (server) {
> future = state.shutdown();
> while (!future.isDone()) {
> server.wait();
> }
> }
> ```
>
> ```java
> try {
> run();
> } finally {
> stopped.complete();
> synchronized (server) {
> server.notify();
> }
> }
> ```
>
> * Version 2
>
> ```java
> synchronized (server) {
> future = state.shutdown();
> }
> future.join()
> ```
>
> ```java
> try {
> run();
> } finally {
> stopped.complete();
> }
> ```
>
> Version 1 and Version 2 seem to be the same. Could you point out when they
will be different?
For version 1, we need to wait for another thread to wake up before
continuing execution.
For version 2, the current thread and the thread that needs to be shut down
may execute in parallel.
--
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]