Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lock/unlock please comment my code

 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please comment my code ...


Thanks,
Tony

[ August 07, 2006: Message edited by: Tony Bouer ]
[ August 07, 2006: Message edited by: Tony Bouer ]
 
Kelly Wood
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean:

in lock()
lockMap.put(new Long(recNo), new Long(lockID++));

in unlock()
lockMap.remove(new Long(recNo));
 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I updated the code ... by the way I would like to give attention to locking mechanism by itself with synchronized method, wait() and notify.

I appreciate any comments on the code !
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With notify in your code, you risk deadlock. Read documentation.
 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
updating ...


[ August 07, 2006: Message edited by: Tony Bouer ]
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read SCJD FAQ.
... you may not post your entire code for locking and unlocking records - this is a major section (currently worth 20% of the assignment) and sections of such code will be removed from any post. Posting just one method (e.g. the lock() method is usually considered reasonable).

There are multiple reasons for this policy:
* Sun do not allow you to share your assignment or a solution to the assignment with others.
* You have spent time and effort getting your solution right. It would not be right for someone else to just copy your solution without working it out for themselves.
* If someone did get awarded the SCJD certification after copying your code, and were then given employment because they had that certification, the employer would probably find that the employee cannot actually do the work. Which makes the perceived value of this certificate decrease.
* If people post too much code, then Sun may, in the future, request that we do not allow any SCJD code to be posted.


Regards
 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Removed code as requested ... I´┐Żll try to describe just the algorithm on the future.
Thanks,
Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic