473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 1350
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
1
by: Chua Wen Ching | last post by:
Hi, I am away from my office PC now, so i can't get my problem codes up. I can achieve this in C# with xmldocument and xmlelement <Device> <ExecuteProcess1 /> <ExecuteProcess2> Test
4
by: Justin | last post by:
Hi, i need some help on this urgently... Thanx.... The situation is like this, i need to find out the way to convert Chinese characters into hexa code. but the problem is what i got from bin2hex()...
19
by: ash | last post by:
hi friends, i have some questions whch is in my last year question papers.i need some help to get logic of these questions. 1) write a C function, that takes two strings as arguments and...
1
by: AlmasKhan01 | last post by:
Hi I have been for sometime now been working on a MineSweeper program and I'm 90% complete on it it involves a window interface and is quite simple but the issue is not. The program is long(to me)...
1
gammyfeet
by: gammyfeet | last post by:
Hi guys, and girls, I fairly new to scripting and kind of understand it, I usualy find scripts and change them to my needs but sometimes I get stuck so it's good to find a place to find/share...
5
by: jkyong | last post by:
I have a code here...anyone care to help me decrypt it? I really need it and i think it's in chinese or maybe not..... </span><br /> <div id="IdBSpdLq" ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.