Hi donny,
A simple implementation would be something like this
//#####################
//Shared Object's probable implementation
//#####################
class SharedClass {
public static lock;
public SharedClass() {
}
public boolean lockStatus() {
return lock;
}
public void setLock(){
lock = true;
}
public void freeLock() {
lock = false;
}
}
//#####################
//Thread implementation
//#####################
class MyThread extends Thread() {
public MyThread() {
}
public void run() {
if(!sharedObject.lockStatus) {
sharedObject.setLock();
// do the processing here.
//unlock here
sharedObject.freeLock();
}
}
}
************************************************** ********
The basic flaw of this code it does not work under unsynchronized
thread enironment. so make sure you make the threads synchronize.
If your using unsynchronized threads environ then probably you must
consider your operating Systems process management and apply such a
algorithm.
All the best.
Giridhar Nandigam.
PS: Programming is an art not a methodolgy. So everything is
programmabale. Hence nothing is hard. You can do better than me.
dd*****@hotmail.com (Donny) wrote in message news:<73*************************@posting.google.c om>...
We have an object that is to be shared across different multi-threaded
nodes in a distributed system. It should be possible to lock that
object using any thread, and the other node which shares the object
should also know that the object is blocked.
Any ideas??!
halp!!
take care everyone,
PDA team, iiit-b, India