Hi,
I have code in my plug-in that I'd like to make sure doesn't run in
multiple threads at the same time.
Of course if there were only the possibility of one management server ever
running at a time, then I could just use synchronized.
What is the recommended CloudStack approach?
I see code like this in places (in a try block):
GlobalLock lock =
GlobalLock.getInternLock(templateIdPoolIdString);
if (!lock.lock(5)) {
s_logger.debug("Couldn't lock the db on the string " +
templateIdPoolIdString);
return null;
}
Then the finally block has this:
lock.unlock();
lock.releaseRef();
Does this achieve what I'm looking for?
Thanks!
--
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: [email protected]
o: 303.746.7302
Advancing the way the world uses the cloud
<http://solidfire.com/solution/overview/?video=play>*™*