core/thread: refactoring