470,862 Members | 1,699 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

Do you see anyone 'Remotely' of some help!!??

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
Jul 17 '05 #1
2 1249
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

Jul 17 '05 #2
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

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by mike | last post: by
3 posts views Thread by Mike | last post: by
4 posts views Thread by Justin | last post: by
19 posts views Thread by ash | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.