On Thursday, 28 January 2016 at 11:53:48 UTC, Russel Winder wrote:
On Tue, 2016-01-26 at 11:44 +0000, nbro via Digitalmars-d wrote:
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.
I don't understand why you say that everyone that uses
synchronized is doing bad concurrent programming. That's not
correct, if you know how to use it. Also, I don't understand why
also lock and monitors should be removed. How would you write
then multithreaded programs?