Currently the read lock is almost never dropped as it's held during the sleep time. So the write lock in the delegator to exit the main loop is never acquired.
Also changed the wait time to limit lock contention.
Ideally, it might be better to use an AtomicBool instead of locking the whole structure.
Currently the read lock is almost never dropped as it's held during the sleep time. So the write lock in the delegator to exit the main loop is never acquired. Also changed the wait time to limit lock contention. Ideally, it might be better to use an AtomicBool instead of locking the whole structure.