File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes Class locks between processes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Class locks between processes" Watch "Class locks between processes" New topic

Class locks between processes

Jamie Burrell

Joined: Oct 05, 2004
Posts: 3

I know the Thread and synchronize functionality allows me to lock objects between multiple threads within the same process, but is there anyway to lock an object between processes?

Case Study:
Process A calls class AccessResource. It utilises this class for 10 seconds before ending.
Process B calls class AccessResource. It cannot access it because class A is using it, and it is locked. It waits for it to be freed, then uses it itself.

Any ideas?

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think you'll have to make the processes talk to each other or some shared external resource manager. We had this conversation on the ranch once before and I thought if the two processes already share a database the database might make a good manager because it has good ACID operations. Flags on a shared file system might be tempting, but I'm not sure they would be reliable. I have a design in my drawer for a resource manager process that a friend did about 20 years ago. Maybe I should dig that out.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Class locks between processes