add thread support and handler