D
D
Drunya20182018-11-05 23:58:52
Java
Drunya2018, 2018-11-05 23:58:52

Is it possible to interrupt a thread in the Thread List?

I have a Thread List. Each thread executes Runnable. Is it possible during the execution of the first thread to interrupt the execution of, say, the third? If yes, how should it look like?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-11-06
@Drunya2018

A thread must manage its own lifecycle on its own. The other thread can only send signals to it, changing the shared state. Use a volatile variable or one of the synchronization primitives.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question