Shutdown curent thread C++ [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Edited.
How to shutdown(to stop it forever) current thread in a class method?
Now, I have:
methodName() {
std::unique_lock<std::mutex> locker(...);
cv.wait(locker, [this]{return ready_ || finished_;});
if (finished_) //need to terminate cur thread
...
}

The question isn't that clear, but if you are working on windows, you cant shut any thread down using TerminateThread or if you want to close current thread, you could use CloseThread.

Related

Thread waiting until a condition is true or a timeout occurs C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I have a thread that must wait until a condition is true or until a timer runs out and I was thinking which would be the best way to solve it, I though about condition variables but I am not sure if is the best method since I could have race condition, I would be happy to hear your suggestion.
Thank you.
A simple way is to have a locked mutex that your thread can wait for. Your timer can then unlock the mutex when you want the thread to continue.

Thread crash detection in Linux environment and c++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I would like to know if there is a way to know if one of my Threads Crashed?
with new c++ methods/libraries or linux system calls
ive been searching the internet and couldnt find a answer to my question

Origins of "joinable" and "unjoinable" in multi-threading [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Why does POSIX use the words "joinable" and "unjoinable" to describe between a thread that is/was/might/could-in-the-future-be doing something and a thread that is idle and waiting to be deleted? What was the initiative behind the selection of these particular words to describe the current state of a thread?
You can maybe use this kind of mental model to explain the terminology:

Notify a specified tread in C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I didn't find anything on the Internet about this, so I'm asking here.
Is there a command in C++ to notify a specified thread and not a casual one?
Use one std::condition_variable for each event you want to wait for.

How to suspend and resume a Process and Thread in C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i wan't to suspend and resume main function is there any way except sleep method. Please Help
Assuming you have other threads running apart from main, you can use use a sem_wait (semaphore initialized to 0) in main() and then from your thread you can call sem_post whenever you want main() to run.
Read about semaphore and usage: