On Tue, 2016-01-26 at 11:44 +0000, nbro via Digitalmars-d wrote: > […] > Moreover, could you also explain why D was designed to > synchronize entire classes instead of single methods. If I > synchronize single methods (in Java for example), I could still > be able to use other non-synchronized methods without needing to > acquire the lock, so I don't understand this decision.
It should be pointed out that anyone using the synchronized keyword anywhere in Java code is doing concurrent and parallel programming wrong. If they are using synchronized in single threaded programming well, then… The issue here is Java monitors, which are massively overweight, and have been since 1994. Indeed the whole wait/notify system is a serious problem. Sadly it took 20 years for people at the heart of Java development to finally admit this in (semi-)public. Doug Lea's, Brian Goetz, and others have over the last 10 years been making things better. A lot better. So good concurrent and parallel Java eshews synchronized, wait and notify, and employs one or more of the thread safe parallel data structure, e.g. ConcurrentHashMap, the futures related things, or more usually now Streams. synchronized, wait and notify along with the lock and monitors should be deprecated and removed. Sadly as we know nothing that is deprecated ever gets removed from Java. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part