473,467 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to check whether the thread had been stopped or not

8 New Member
Hi,
I am trying to connect a device through a port. while making an attempt, i am going for the following commands

synchronized(this)
{
this.wait(10000)
}
.
.
.
if (!xyz.isConnected())
{
String error = "Connection error: Unable to connect host";
xyz.displayErrorOnTerminal(error);
}

the problem is the connection is not made within this given time. so it displays an error msg. but after some 30 sec, the connection is established. from this i came to understand that some thread is running behind, it completes the job.
for this i cann't change the wait time, its as per design.

so can any one give me a solution, so that the msg should not print until the thread stops.ie...it should not come for if statement untill the thread completes its job.

Thanks...
Babu Shanmugham
Oct 16 '06 #1
1 2076
r035198x
13,262 MVP
Hi,
I am trying to connect a device through a port. while making an attempt, i am going for the following commands

synchronized(this)
{
this.wait(10000)
}
.
.
.
if (!xyz.isConnected())
{
String error = "Connection error: Unable to connect host";
xyz.displayErrorOnTerminal(error);
}

the problem is the connection is not made within this given time. so it displays an error msg. but after some 30 sec, the connection is established. from this i came to understand that some thread is running behind, it completes the job.
for this i cann't change the wait time, its as per design.

so can any one give me a solution, so that the msg should not print until the thread stops.ie...it should not come for if statement untill the thread completes its job.

Thanks...
Babu Shanmugham
Maybe

Expand|Select|Wrap|Line Numbers
  1. if (!(xyz.isConnected() && thread.isAlive()))
  2. {
  3. String error = "Connection error: Unable to connect host";
  4. xyz.displayErrorOnTerminal(error);
  5. }
where thread is the thread that is supposed to complete the job.
Oct 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: John Roth | last post by:
PEP 263 is marked finished in the PEP index, however I haven't seen the specified Phase 2 in the list of changes for 2.4 which is when I expected it. Did phase 2 get cancelled, or is it just not...
10
by: Clive Backham | last post by:
I tried posting this on comp.infosystems.www.misc, but that group appears to get very little traffic. So now I'm trying here. If there is a more appropriate group, please let me know. I'm...
2
by: Ken Durden | last post by:
I'm setting up an interface where clients must perform external locking before calling certain commands. I do this to force them to specify the duration the action they performed must persist...
10
by: Nikola Skoric | last post by:
Hello there, Lets say I have something like this in my Mother Of All Threads: Thread thread1 = new Thread(new ThreadStart(this.run)); thread1.Start(); //some unimportant code...
170
by: I_AM_DON_AND_YOU? | last post by:
Whether we can upload the projects (in .zip format) in these newsgroups? I am asking this because earlier there are more than 50 posts (in one thread) about this query and they are contradicting...
7
by: Ford Prefect alias Armin | last post by:
I want to start a Thread and wait till the Thread has been stopped (via Suspend) How to do this. Sub Test Start Thread Wait Till Stopped Go on with this code as sone as the Thread has...
12
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
0
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
I read from a serialport using a worker thread. Because the worker thread t does not loop often, I cannot wait to terminate the worker thread using a boolean in the While condition. So I have a...
0
by: TeenaRoz | last post by:
Hi, Can some one help me in finding out why this exception occurs when ever I try to load a particular JSP page? Oct 29, 2008 4:23:54 AM org.apache.catalina.loader.WebappClassLoader loadClass...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.