core: start to use task instead of seperate thread