Leave the main function of a thread when the mode has changed
When the mode changes, some threads should passed to sleep state, but it doesn't. There is nothing that makes them leave their main loop in the file subprogram.c.
This function should end when the mode is not the same.