Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7009683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:53:36+00:00 2026-05-27T21:53:36+00:00

I put up many threads running. At a later time, I’d like to check

  • 0

I put up many threads running. At a later time, I’d like to check if these threads are still alive (i.e., not finished yet and not terminated unexpectedly).

  1. What kind of information should I keep track of regarding the threads in the first place. Thread ID, process ID, etc? How should I get these IDs?

  2. When I need to check the liveness of these threads, what functions should I use? Will pthread_kill work here? pthread_kill takes an opaque type pthread_t as parameter, which I believe is typically an unsigned long. Is pthread_t different from a thread ID? I assume a thread ID would pick up an int as its value. In some tutorials on pthread, they assign an integer to a pthread as its ID. Shouldn’t the thread get its ID from the operating system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:53:37+00:00Added an answer on May 27, 2026 at 9:53 pm
    1. A thread’s entire identity resides in pthread_t

    2. Initializing a thread returns its pthread_t typed ID to its parent

    3. Each thread can get it’s own ID with pthread_self()

    4. You can compare thread IDs using the function:int pthread_equal (pthread_t, pthread_t)

    So: Maintain a common data structure where you can store thread status as STARTED, RUNNING, FINISHED using the pthread_t IDs and pthread_equal comparison function to differentiate between the threads. The parent sets the value to STARTED when it starts the thread, the thread itself sets its own state to RUNNING, does its work, and sets itself to FINISHED when done. Use a mutex to make sure values are not changed while being read.

    EDIT:
    You can set up a sort of ‘thread destructor’ using pthread_cleanup_push:
    http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_cleanup_pop.html

    i.e. register a routine to be called when the thread exits (either itself, or by cancellation externally). This routine can update the status.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have MANY small Test Projects where I put together just enough code to
Possible Duplicate: How many Python classes should I put in one file? Coming from
I am trying to pull registry info from many servers and put them all
i want to put a newline into a txt file, i tried with many
How does Python evaluate the expression 1+++2 ? How many ever + I put
I am launching many threads simultaneously, each one writing / reading data into/from a
Simple experiment has shown that JDK7 compiled HashMap<Integer, Integer> uses many threads when performing
I'm sure the answer to my issue is a combination of many threads already
I've created many Geodata objects (name,postalCode,lat,lon). Now I want to put them into a
A long running shell script produces stdout and stderr, which I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.