Reputation: 4525
I was trying to understand how guava's AbstractService has been implemented. In the interface Service the various state transitions have been mentioned. One such transition is from STOPPING -> TERMINATED when the call to stop() is successful.
Now when I am seeing how AbstractService's stop() has been implemented, I found that on case STOPPING, they fall through and don't change the state to TERMINATED.
I may be wrong, I am just trying to learn and understand how it works.
The code for AbstractService class is given here. http://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/util/concurrent/AbstractService.java?r=8d5659ad0e137d3a594014793264292a75b48bb9
Search for stop() on the page to see its implementation
Upvotes: 1
Views: 240
Reputation: 110054
When you call stop()
in the RUNNING
state, the state is changed to STOPPING
and the doStop()
method gets called. Calling stop()
again after that shouldn't do anything. The doStop()
implementation should call notifyStopped()
which changes the state from STOPPING
to TERMINATED
.
Upvotes: 4