?
Solved

Wait for a thread to exit for limited time on linux

Posted on 2007-04-11
3
Medium Priority
?
700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Accepted Solution

by:
slyong earned 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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