underselling the sync/suffer problem
21 Jul 2011, 13:53
Brian Tarbox (41 posts)
I’ve been drinking the Scala coolaid after years of java synchronized and suffer problem. There is one major synchronization problem that I’m surprised you didn’t touch on: fairness. In Chapter 10 you talk about the inadequacy of making the setters and getters synchronized…saying that you need to put a synchronized block and a get then set block. The problem is that synchronized blocks are not guaranteed to be fifo and in fact will generally be lifo. So just making a synchronized block isn’t enough…you have to use a fair lock to both preserve correctness and ensure timeless of response.
Perhaps this would be considered piling-on to java’s problems here but its a problem that has caused many people lots of trouble.
|You must be logged in to comment|