News for hackers. Stuff that matters.
Re:Things You Didn’t Know About Synchronization in Java and ... by kailuowang on Thursday August 15, 2013 @08:47AM (#6217416)
> Practically all server applications require some sort of synchronization between multiple threads.

It could be just me but I think the author should've mentioned alternative concurrent programming models available for JVM such as Akka.

Re:Things You Didn’t Know About Synchronization in Java and ... by kasey_junk on Thursday August 15, 2013 @09:18AM (#6217554)
Just remember under the covers Akka is still using synchronization.
Re:Things You Didn’t Know About Synchronization in Java and ... by asperous on Thursday August 15, 2013 @02:00PM (#6219535)
You mean internally? The paradigm they use is immutable-message passing and asynchronous/concurrent processing.
Re:Things You Didn’t Know About Synchronization in Java and ... by kasey_junk on Thursday August 15, 2013 @03:12PM (#6219935)
Yes internally. Somewhere deep in the bowels of the akka code, they are communicating state between threads (last I checked they were using a java concurrent queue by default).

At a bare minimum the changes to the location of the head/tail of a queue will need to be visible to multiple threads requiring volatile variables.

The java concurrent queues don't actually use synchronization blocks, they use native CAS operations but thinking that akka removes shared thread state entirely is dangerous.

Re:Things You Didn’t Know About Synchronization in Java and ... by benjaminwootton on Thursday August 15, 2013 @09:21AM (#6217570)
Even lots of low latency standard Java is tending towards single threaded non blocking models without synchronisation.

The costs of synchronised blocks is high on the JVM. They defer to the operating system for thread scheduling, they enforce a memory barrier meaning all data is flushed out to RAM rather than CPU caches, and multithreaded code dirties CPU caches, reducing performance.

More server side code should be single threaded than not in my opinion.

Re:Things You Didn’t Know About Synchronization in Java and ... by kasey_junk on Thursday August 15, 2013 @09:36AM (#6217642)
You can write lock free algorithms that are not single threaded as well. If you design your system so that only 1 thread is doing the writing of data you avoid a lot of the negative performance implications you mention.

That said, I completely agree. Many times making a single threaded system faster will improve performance vs making it parallel.

Re:Things You Didn’t Know About Synchronization in Java and ... by AndreasFrom on Thursday August 15, 2013 @08:50AM (#6217429)
Clojure's STM is also an interesting model.