Hi everyone,
I am still having a hard time to understand the difference between concurrency and asynchronous.
I have asked the question about how we can achieve highly concurrency in elixir here and all the answers really helps a lot.
But, I recently view the presentation about modern java non-blocking library like Reactor or RxJava. I think they are non-blocking java library and helps to use resource more efficiently and asynchronously.
My understanding about reactor is as follow:
- They also use 1 thread for each cpu cores
- Use event loop mechanism, ie. when there’s a request come in, they do the book keeping (register request and its callback) and move it to the waiting queue so that the system can continue serving more request. When there’s result comeback then the callback is put in the event queue and processed by event loop.
So basically I think it was also like elixir where one scheduler thread run processes when needed ?
So I think reactor is also highly concurrent if the “task” is IO-bound ? And in this case, elixir and java reactive library is the same ?
And elixir only prove more concurrency when the “task” is cpu-bound ? I am still not sure how the event loop will behave in that situation because I think the code in the callback should be very quick to avoid blocking the entire system.
Another question is that library like reactor support the reactive streams specification. I also read in one of the blog post saying that otp which is based on actor model is also provide built-in support for reactive streams. Can you help to explain that ?
I would appreciate your feedback on this questions. Thank you so much?