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#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...