Changed the definition of setUserContext method to make it thread safe