Java v Scala from a concurrency viewpoint -


I am removing the project from my last year now. I am checking the concurrency approach from Java and Scala approaches. After coming out of the Java Concurrency module, I can see why people say that it is difficult to argue about shared state threading approaches. Due to running non-deterministic Java threads, you have worrisome classes, the situation of anxiety and deadlock, etc. to run the risk. This argument with 1.5 was given some clarity, but still, it is clear away from crystals.

On the first scene, Scala appears to remove this complex logic through artists. This has given the programmer the ability to develop a concurrent system from a more sequential approach and make the concept easier. But, for this positive, am I saying that there are some drawbacks? For example, we say that we want to sort a large list in both scenarios - with Java, you split two threads into two, worry about serious sections, atomic functions etc. and go to code Scala With, because this is "nothing shared", you actually have to list two artists / 2 stars for the orderly operation, okay?

I think my question is, at what price do you pay for simple argument, what is the performance of overhead to cross the collection for their actors?

I was thinking of doing some benchmark tests for this effect (Selection sort, Quick sort etc.;) But because one is functional and one is essential - I compare Apple with an algorithmic approach I will not.

I appreciate any of the above ideas so that I get some ideas to start me. thanks a lot.

The good thing about Scala is that if you want you can concatenate like Java . All Java classes are available.

So it really boils down to the difference between a model where you have threads with concurrent access to temporary variations, and a model where you have skilled artists who send messages to each other but one Do not peek in the interior of the other and you are absolutely right that in some circumstances you have to stop the performance against the ease of the code.

I usually have a great rule of thumb that if you are using Threads to spend a significant amount of waiting to open the lock using a heap Java model, and every There is no clear way to avoid waiting for that resource to work, and if the execution quickly switches between the threads, the Java model is far better than an actor model, where the actor is a " Zhe-up "message is sent back to a supervisor, who sends the" "new work here again! Depending on sorting message algorithms to an existing non-busy actor, how do you visualize them, come in this category a lot.

For everything else, the functionality of artists related to penalties is not as much as I have seen. If you can conceive as many of your problem and reactive elements (i.e. only need a time when a message is received), then the actor is especially well (millions of available < / Em>, although only a few handfuls are working on any instant); With Threads, you need to have some extra internal state to track which work should be done, because you can not handle that many active threads.

Comments