Update api for more flexible thread support