This question is in my mind about a year. Actually are there any differences in Asysnchronus and Non-blocking. When we call the blocking part in our code then it becomes blocking which is synchronous and at the same time it will not be non-blocking.
If we are creating another thread apart from main thread to make asynchronous programming and we have to return some value so we have to define join()
method in java and join()
is blocking operation then is it actually asynchronous?
I need to know answer for the following questions
If blocking is similar to synchronous then what is the different between asynchronous and non blocking. Should it be similar ? if not then why?
Reactive Programming which is non blocking does it fully asynchronous programming?
Consider 2 parallel algorithms, producer and consumer. If consumer works faster than producer, we have to block consumer algorithm until producer provide new data. Generally, we have 2 ways to block consumer:
The first method of implementing consumer is synchronous, and the second asynchronous.
Now consider an opposite case: producer is faster than consumer. Then again, we have two options to block producer:
Naturally, the first option is synchronous and the second asynchronous. And the second, asynchronous option to define interaction between fast producer and slow consumer is called reactive programming
.
So, reactive programming is a subset of asynchronous programming. There are many different protocols to define interaction between asynchronous activities, and reactive programming is only one of them, which is unable to cover all possible cases of asynchronous communications.
I tried to collect asynchronous protocols in the module https://github.com/akaigoro/df4j/tree/API-8/df4j-protocols. Other protocols can be (re)invented, for example, byte streams with or without backpressure, analogue to synchronous InputStream and OutputStream. I am sure any synchronous protocol has its asynchronous analogue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With