Last active
December 22, 2015 07:38
-
-
Save msimonin/6438913 to your computer and use it in GitHub Desktop.
lock object
suspend thread for a while.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Object lockObject_; | |
/** Run method. */ | |
public void run() | |
{ | |
try | |
{ | |
while (!isTerminated_) | |
{ | |
// do something here | |
synchronized (lockObject_) | |
{ | |
lockObject_.wait(monitoringInterval_); | |
} | |
} | |
} | |
catch (InterruptedException exception) | |
{ | |
log_.debug(exception.getMessage()); | |
} | |
terminate(); | |
log_.debug("Group manager summary information producer is stopped!"); | |
} | |
/** | |
* Terminating the thread. | |
*/ | |
public synchronized void terminate() | |
{ | |
log_.debug("Terminating the group manager summary information producer"); | |
synchronized (lockObject_) | |
{ | |
isTerminated_ = true; | |
lockObject_.notify(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment