Synchronous vs Asynchronous and Blocking vs Non-Blocking

wahyu eko hadi saputro
3 min readAug 2, 2022

--

ok, at this time i will write about synchronous vs synchronous and blocking vs non-Blocking. actually the term synchronous, synchronous, blocking, non-blocking is important for programmer, on many book or tutorial about programmer we will find the term synchronous, synchronous, blocking, non-blocking so often. ok lets deep dive about it:

Thread is a list / set of instructions, we can imagine a road is the list and a car is the instruction.

Synchronous

Characteristic of synchronous :

  • Waiting until the process is completed
  • The thread is blocked while occupied by a process / instruction, until the process is completed

we can re-use the thread A, after the instruction on thread A is completed.

Asynchronous

Characteristic of Asynchronous :

  • Not waiting the process completed
  • The process is assigned to another thread

main threadA will spawn child ThreadA, and assign an instruction to the child thread, and the main thread is also able to use callback function to know the instruction status on the child thread. On case main threadB, the main thread don’t care about the instruction status on the child thread.

Blocking

Characteristic of blocking :

  • Only one thread can be proceed on the single point of time
  • Another thread will be on waiting state

ThreadB is occupying the method by doing some locking mechanism, so that another threads need to wait until the locking is released.

Non Blocking :

Characteristic of blocking :

  • Can serve many thread on the single point of time

The non blocking method can handle many thread at same time.

Synchronous Blocking

the thread1, thread2 and thread3 is synchronous, but the process is blocked by something whether blocking method, I/O blocking, etc

Synchronous non-blocking

Asynchronous Blocking

Asynchronous Non- Blocking

--

--

No responses yet