This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Locking...  RSS feed

Anton Golovin
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, friends.

There are lots of questions on locking, I think, and I think it is appropriate to point people to the most approapriate solution looked for by Sun in the scope of their requirements of "wasting no cycles"...

People familiar with this concept will know that wasting no cycles does in fact mean that the notifyAll() method does not fit this requirement. (I used this method, however, and got 72/80 on locking, which could be due to other mistakes...) However, if they penalize people for it or not, notifyAll() still does waste cycles.

The only way to do it is to use monitor objects in a queue and sequentially call notify() on them.

There is a second part to locking. It is unlocking. Make sure that a record is always unlocked after it is locked - even if something fails.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!