LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-10-2005, 09:04 AM   #1
durga324
LQ Newbie
 
Registered: May 2005
Location: india
Posts: 2

Rep: Reputation: 0
threads state


hi all,

i am having a process which is going to create two more threads. and my main process which created the threads has to monitor the threads status periodially ,and if any thread is cancelled it has to recreate the thread.

can any one suggest a way to monitor the threads from the main process which is created the threads.
 
Old 06-13-2005, 06:36 AM   #2
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Rep: Reputation: 30
What language are programming in? If it is C, do you use POSIX threads (the ones in glibc)? If yes, you could Condition Variables (see the glibc manual for details).
 
Old 06-16-2005, 10:26 AM   #3
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
The dumb solution:

for each thread, create a keep-alive thread which basically does
Code:
while(true) {
    t = new thread
    join(t)
    delete t
}
 
Old 06-17-2005, 08:18 AM   #4
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Rep: Reputation: 30
no seriously, to do something very similar to this in a clean way, you have something called Condition Variables in POSIX Threads. Just check out the manual and google, it is very easy to use...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM
Greetings from NY State npaladin2000 LinuxQuestions.org Member Intro 3 08-05-2005 05:56 AM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 05:58 AM
The State of Wine? itsjustme Linux - General 5 01-19-2004 06:51 PM
Must state im just a messanger :+) theneoprotocol Programming 1 04-10-2002 09:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration