That’s probably because there are some dependencies that are resolved differently in each case, depending on who is calling this method.
In some frameworks, you have something like a state, when request come then the server initializes some variables, for instance a session object for the particular user in which you can store some information. If you call the same method from other Thread without the session being resolved against any user then you have no session at all and it could fail.
But this is not restricted to session, there could be other variables you are using that are initialized (or not) depending on who is calling the method.
9
solved same function working differently when called from two separate functions with same parameters [duplicate]