133tosakarin commented on PR #1168:
URL: https://github.com/apache/ratis/pull/1168#issuecomment-2421278550

   > > For version 2, the current thread and the thread that needs to be shut 
down may execute in parallel.
   > 
   > No. `future.join()` means that it is waiting for `stopped` to complete.
   
   
   
   > > * 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.
   
   
   
   > > For version 2, the current thread and the thread that needs to be shut 
down may execute in parallel.
   > 
   > No. `future.join()` means that it is waiting for `stopped` to complete.
   
   I seem to know!
   
   Only when thread a enters future.join can the state thread execute.
   
   So, is it possible to modify the content of the server when the state thread 
executes?


-- 
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