I have some code that I want to only allow access to by one thread. I know how to accomplish this using either synchronized blocks or methods, but will this work i
Since you are talking about 2 machines, you don't even have shared memory so there is nothing to synchronize.
We do something similar with our database. This is achieved by adding record versioning in the table. This is what you should do,
You should only have one server updating the database if you follow these rules.