Solved

Wait for a thread to exit for limited time on linux

Posted on 2007-04-11
3
688 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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