Concurrency - Thread Safety Problems

Be aware thread safety when considering using Static/Const, Concurrent access to a shared resource can lead to Thread Safety issue. To avoid,  Ensure the access to that resource must be serialized. This can be achieved by using mutex or any higher-level objects such as critical section. 

Below are the source code

 

private static String currentUser;

private String originalUser;

To fix use:

 static char const*const a[]

In this lab, login from one browser use jeff as username and the other browser login as david, outcome is jeff's login is overwrited by david

Now both browser shown login by jeff.

 

Please publish modules in offcanvas position.