"dlugi" <> wrote in message
news:efuavo$cot$...
> Hi!!
>
> I would like to synchronize access to one resource with two different
> applications working in two virtual machines. Is there some technology
> which enable to block access to resources (e.g. file, network etc) -
> something like global semaphore.
>
> I consider to use JavaSpaces but this mechanism is very slow.
> So, has anybody similar problem??
Before you begin I think you first have to say what the resource is and how
you plan to access it from two different JVM. If the resource is a file
(something outside the JVM) and you just need a global lock you can use a
TCP port. The code for accessing the file first tries to allocate a server
port for a high number. If the access succeeds, you get to use the file.
When you're done, release the port. If the port is already allocated, wait
a little while and try again.
If the resource is some Java thing, you're better off with RMI, which does
not have to have a big overhead. There are techniques for exporting objects
with just a few lines of code (I've posted some here before.)
Matt Humphrey
http://www.iviz.com/