By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,739 Members | 2,014 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,739 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.