add multi-threads branch and update some codes