You are testing two very different codes. Consider Java, for example:
while (true) {
Where is the opportunity for other "actors" to take the thread and do their own processing? This "actor" pretty much chases the thread. If you create 100,000 of them, you will see that the JVM will be crushed under the weight of competing "actors", or see how some of them get all the processing time, while others languish.
Event event = queue.take(); if (event == sentinel) {
Why do you pull the event out of the queue without checking if it can be processed or not? If it cannot be processed, you will lose the event. If you add it back to the queue, it will be completed after other events sent by the same source.
These are just two things that Scala code does, but Java doesn't.
source share