In G1ServiceThread, there is a race between stop_service and the termination check in sleep_before_next_cycle. The latter checks should_terminate outside the lock, and then enters the monitor and waits for notification or the next task to be ready. If stop is requested after the should_terminate check but before entering the monitor, the stop request will be missed. The should_terminate check should be (re)done after entering the monitor. It will eventually terminate if there are periodic tasks, but only when the next task becomes ready.