Add multil-thread support