Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threading

 
Tim Adam Cooper
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Java Developer project (FBNS),it stated that I am required to do lock/unlocking by blocking etc.
Must I use Threading to achieve locking/unlocking? I ask this question because I have done locking/unlocking without using Threading and the program work fine in that only one user can update a record at a time.
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Must I use Threading to achieve locking/unlocking? I ask this question because I have done locking/unlocking without using Threading and the program work fine in that only one user can update a record at a time.

What do you mean exactly ? If you mean implement locking/unlocking within a multithreading environment, the answer is YES : "Your server must be capable of handling multiple concurrent requests".
In your lock method, the calling thread must acquire a lock (monitor) on some object, and wait() ("consuming no CPU cycles) till it's notified, and there are multiple ways to achieve this.
The fact that only one user can update a record at a time has no influence (IMO) on the way locking must be implemented according to its own specs.
Regards,
Phil.
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using RMI, then your server side will be implicitly multithreaded anyway. You just need to ensure that the server can handle it without data corruption.
ms
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
es, getting an Object's lock and calling wait() and notifyAll() are the ways to meet the requirements. Thats the quick answer.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic