Seems more thread-safe.

Deleted some useless code.
It ensures real-time.
But not that reliable to get all the jobs done while the program is
closing.