How do you stop a thread?

How do you stop a thread?
Answer
Modern ways to suspend/stop a thread are by
using a boolean flag and Thread. interrupt() method. Using a boolean flag: We can define a boolean variable which is used for stopping/killing threads say ‘exit’. Whenever we want to stop a thread, the ‘exit’ variable will be set to true.
 

Tìm kiếm

Back
Top