Meaningless Drivel is fun!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes locking issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "locking issue" Watch "locking issue" New topic
Author

locking issue

Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
Hi, I have the following problem. My instructions say, that I'm required to implement (among the others) a lock method, which can look like this.

// Locks a record so that it can only be updated or deleted by this client.
// bla bla bla...
public long lock(int recNo) { }

How is it possible to do it with this argument? I would like to add clientId as a second argument, but this will violate the contract. I implemented my service as a singleton, so I cannot have multiple instances for each client (this would be hard to maintain). How would you conform that requirement without making a spaghetti architecture?
Rudolph Jen
Ranch Hand

Joined: Nov 17, 2006
Posts: 37
You don't need a clientId. Use synchronized/wait/notify instead. Java helps us to supply multiply threads. I am "very happy" that I don't have to handle additional clientId's; keep it simple

Hope that helped.

Best Regards,
R


SCJP<br />SCJD (in progress)
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
Thanks, good idea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: locking issue