Fixed race condition when a thread call more than one user function