refactoring on thread and scheduler finished