[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: Why failoverValve has the ThreadLocal routine
timfox
do-not-reply at jboss.com
Sun Feb 25 03:34:25 EST 2007
I've just woken up and this is off the top of my head, untried, but how about something like this:
| lass Valve
| {
| private int count;
| private boolean locked;
|
| public synchronized void enter()
| {
| while (locked)
| {
| wait();
| }
| count++;
| }
|
| public synchronized void exit()
| {
| count--;
|
| notifyAll();
| }
|
| public synchronized void lock()
| {
| if (locked) return;
|
| locked = true;
|
| do
| {
| while (count > 0)
| {
| wait();
| }
| }
| }
|
| public synchronized void unlock()
| {
| if (!locked) return;
|
| locked = false;
|
| notifyAll();
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4021915#4021915
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4021915
More information about the jboss-dev-forums
mailing list