Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NX: Multiple Threads perform updates

 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just suddenly think of a question.
For the network mode, if there are 2 users on 2 different machines, connects to the same server, and perform the update task, what should I do?
According to the instructions in the assignment, this case is not mention.
Still, I think only 1 user (FCFS-based) should update the record, and the other requests are rejected. But, how should I handle this case?
Get a lock on item X, check before update, if it is already non-empty, then
throws an AlreadyBookedException?
Thanks a lot.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12056
232
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nicholas,
I think you are on the right track here.
What exception you throw, or how you handle that case, depends in part on what your signature for the update() method is.
Regards, Andrew
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!