closed #4123:fixed thread deadlock if new functions are added in callback.