[jboss-user] [JBossCache] - TreeCache: How to write atomic updates?
kapilanand
do-not-reply at jboss.com
Tue Sep 26 12:00:27 EDT 2006
hi all
I am trying to do the following from two or more hosts that are part of a JBossCache group. (I am using JBossCache 1.4)
If exists(FQN, key)
{
lock FQN
value = get(FQN, key)
value--
if (value == 0)
{
remove(FQN, key)
}
else
{
put(FQN, key, value)
}
unlock FQN
}
There is another thread of code that will increment the value. increment and decrement may happen on any of the hosts.
My intention is only to lock the map and i guess that is only achieved by locking the FQN node. Please correct me if i am wrong.
My question is "how to explicitly lock and unlock the nodes?"
Javadoc for TreeCache._lock() has one-liner saying "Should not be called." I see _releaseAllLocks() and releaseAllLocks().
And is there a mechanism for timing-out the lock. That is what happens if the process/thread that locked the node dies?
thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974273#3974273
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974273
More information about the jboss-user
mailing list