> Does anyone know how I can create a mutex to control access to a shared
> resource on one computer?
In the Java VM? Each object has a monitor associated with it, which can
be used as a recursive mutex.

Signature
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
> Hello all,
>
[quoted text clipped - 3 lines]
> Regards,
> Q. Noble
It depends on where you want to control access from:
1. All clients in a single JVM -- that is all clients of that shared
resource have their lifecycles within a single JVM
or
2. The clients are in different JVMs.
(or)
2b. The clients are different entities, at least one of which is not even a
JVM.
1. is the easiest because any object can be used as a mutex. If the shared
resource is represented by an Object, simply synchronizing around it will do
the trick.
2 and 2b. require that you use some OS specific synchronization resource.
For example, you can use a UDP or a TCP socket which is bound to a
particular port as a mutex. To gain control of the shared resource, a
client must gain control of the mutex first. In this case, this can be done
by opening a socket at a chosen port number. If the client suceeds in doing
so, it can assume access to the shared resource. When done, it closes the
socket. Other clients can then make use of the shared resource.
Of course, the above are simplistically stated, but I hope they give you
some ideas.
HTH,

Signature
Shripathi Kamath
NETAPHOR SOFTWARE INC.
http://www.netaphor.com
Jim Hansson - 12 Aug 2003 22:32 GMT
>> Hello all,
>>
[quoted text clipped - 33 lines]
>
> HTH,
for 2 and 2b you could setup the shared resource to be a remote object with
RMI, should that not solv it?
Jim