Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Vinay Selvaraj

Greenhorn
+ Follow
since Aug 25, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vinay Selvaraj

Finding records quickly is not a project requirement. Dont waste your time on it. The graders wont care if it takes 1 second to find a record within their test database of ~20 or if it takes 100 milliseconds.

The graders wouldn't want to spend too much time trying to understand how your application works. Keep them happy by making your app small and simple. Dont do anything more than you have to.

Good luck!
Locking needs to be done in the Data class. The server will use the Data class.
Yes. When I said "smaller is better", I meant synchronize only what must be synchronized. In some cases, it may just be better to synchronize a small block of code within a method and not the entire method.
Udham ,

What if those two thread are trying to lock the same record. To make it thread safe, you'll have to have a synchronized block somewhere. Smaller the better.

Originally posted by Anton Golovin:


My Data class is synchronized.



Only methods and code blocks can be synchronized. Did you synchronize the method that calls waitForUnlock?
You'll need to synchronize the method for it to work properly. More than one method may be running this method at the same time.