Be warned that this is mostly just a collection of links to articles and demos by smarter people than I.
Areas of interest include Java, C++, Scala, Go, Rust, Python, Networking, Cloud, Containers, Machine Learning, the Web, Visualization, Linux, System Performance, Software Architecture, Microservices, Functional Programming....
With the new C++11 Standard, C++ faces the first time the challenges of multicore architectures. The 2011 published standard defines how a C++ program has to behave in the presence of multiple threads. The C++11 multithreading capabilities are composed of two components. This is on the one hand, the defined memory model, which is on the other hand, the standardized threading interface.
In Java, a thread is "blocked" when it's waiting for a "monitor" on an object. When I originally googled this I was like "er what's a monitor?". It's when you use synchronization to make sure two different threads don't execute the same code at the same time.
// scala pseudocode
class Blah {
var x = 1
def plus_one() {
this.synchronized {
x += 1
}
}
}
This synchronize means that only one thread is allowed to run this x += 1block at a time, so you don't accidentally end up in a race. If one thread is already doing x += 1, the other threads end up -- you guessed it -- BLOCKED.
The two things that were blocking my threads were:
lazy vals in Scala used synchronized internally, and so can cause problems with concurrency
Double.parseDouble in Java 7 is a synchronized method. So only one thread can parse doubles from strings at a time. Really? Really. They fixed it in Java 8 though so that's good.
Jessica Kerr covers some of the concurrency tools existing in JVM languages including ExecutorService, Futures, Akka actors, and core.async coroutines, providing advice on writing deadlock-free code.
I've recently visited #jcrete, a Java Un-Conference. After talking with people, it struck me that many things that were available and extremely popular in the other communities (like Clojure and Haskell) are still so little used in Java world.
Ever since Java got Lambdas, Streams and default method implementations in Interfaces, it actually became much more enjoyable language to use. It should have also changed ways people write their code, although this process is much slower than I would have expected.
Lambdas allowed us to pass anonymous functions in order to avoid creating a class for every single possible clause where variables escape the context. They also allow to think of operations in terms of small, atomic pieces that can be combined, passed around, reused and referenced.
In this post I’ll try to examine the question of lockless concurrency in Java - an extremely useful, yet shamefully overlooked topic. Implementing lockless algorithms and data structures requires some intuition on basic principles, so let's start with something simple.