This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class locks between processes
 
Similar Threads
Scheduling jobs with the web container
are RUP & UP totally different ?
How does multiple calls to lock cause Deadlock?
Qn on Threads
Tests for the Data class/locking mechanism