Solved

Wait for a thread to exit for limited time on linux

Posted on 2007-04-11
3
680 Views
Last Modified: 2008-02-01
Using pthread_join(), one could wait for another thread to exit. But the pthread_join does not take a time argument, so if the other thread gets stuck and doesn't exit, the pthread_join doesn't return. Is there a way to wait for a limited time, say 5 seconds? If the other thread doesn't exit, then the calling thread could continue its own journey. Thanks a lot.
0
Comment
Question by:shibai
3 Comments
 
LVL 24

Accepted Solution

by:
slyong earned 500 total points
ID: 18894958
Hi shibai,

There is a long discussion about why pthread_join() has not timeout arguement.  Essentially, the library already provides enough primitives for someone to implement a timed join on their own, so none is provided. A sample implementation is also provided.

http://www.opengroup.org/onlinepubs/000095399/xrat/xsh_chap02.html#tag_03_02_08_21
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
low latency kernel configuration 3 174
Linux  : how to view CPU info and  its usage details 7 251
how can i fully uninstall a puppet client? 2 102
Problem to run file 9 104
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now