posted 11 years ago
Srini,
This is an example of thread unsafe code. There are many ways you could make your code thread unsafe
the above code is thread unsafe. Let's say 2 users are using your system at the same time, and User A is trying to update records, and user B is trying to logout, the updateRecord and the logout method will execute concurrently, or in simple terms, both methods will run at the same time. Depending on the sequence of operations, userId can be set to user A when logoutUserById is called. This means that user A will be logged out, not user B.
I'm not saying that this is the problem. I'm just saying that if you have thread unsafe code, it might look to the end user that the "session" is being shared between users. If you have eliminated everything else, look at thread safety