I have a thread pool that reads command objects from a queue. Each command object is an implementation of an abstract command class with a single execute() method, i.e. the command pattern.
I want to implement a command that makes the thread stop itself, i.e. the execute() method stops the current thread. Usually I would just return from the thread function, but I need to stop the thread from the execute() method.
What is the best way to do this? I can use detach or destroy, but the main program calls join on all threads and I’m not sure if it will work. Assume everything the thread has access to has been unlocked.
Aucun commentaire:
Enregistrer un commentaire