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 5997583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:17:04+00:00 2026-05-23T00:17:04+00:00

I was thinking of the following scenario happening while a pthread is running: pthread_mutex_lock(…);

  • 0

I was thinking of the following scenario happening while a pthread is running:

pthread_mutex_lock(...);
... // <- Thread dies here
pthread_mutex_unlock(...);

in other words, a pthread starts, at some point it locks a mutex, and for some reason, it dies before it is able to call the matching unlock function, either because another thread killed it, or the OS itself (android in this case), decided it needed to kill it for some reason or other (it needed to do other things, etc.)

Would this ever happen on android (or any other OS really) without you invoking a pthread_kill() or something like that, and even if you did, what is the proper way to avoid just such a thing from happening? Thank you.

  • 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-23T00:17:05+00:00Added an answer on May 23, 2026 at 12:17 am

    Killing threads is never very useful. (unless you can afford to SIGKILL/abort the whole process anyway).

    Instead unwind the stack with an exception and use RAII. If your process/OS has become so unstable that random thread aborts happen, I think you’ll have other worries and the resulting mess is not the process’ responsibility.

    Just Don’t pthread_kill

    Also, all of this might become slightly more interesting when using inter-process sync primitives. In that case, though, I think Linux kernels guarantee that any locks held by a process will be released when that process is terminated, whatever the cause

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

Sidebar

Related Questions

From couple of days i am thinking of a following scenario Consider I have
All, I'm looking for advice over the following scenario: I have a component running
I'm thinking today at the following scenario: I have two classes A and B.
assume the following scenario: while(!notTheEnd) { char str[1024]; char* ptr_to_str; /* some strcat, strcpy
I'm thinking the following: Netbeans + FlexBeans Maven + FlexMojos However: FlexBeans just doesn't
So, I'm thinking of having the following centralized setup with Git (each of these
Thinking that the answer to this is pretty obvious but here it goes: When
Scenario I have the following methods: public void AddItemSecurity(int itemId, int[] userIds) public int[]
Original Question Consider the following scenario: public abstract class Foo { public string Name
Here's the scenario; I have a list of CustomerIds (1, 2, 3) that have

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.