aspose file tools
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Class locks between processes" Watch "Class locks between processes" New topic
Author

Class locks between processes

Jamie Burrell
Greenhorn

Joined: Oct 05, 2004
Posts: 3
Hi,

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?

Thanks,
Jamie
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Class locks between processes
 
It's not a secret anymore!