Skip to content

Blocking function vs Suspending function

Devrath edited this page Jan 11, 2024 · 4 revisions

Blocking Function

  • Blocking functions are those, whose execution will block the program as a whole and will not continue until the blocking function has completed its execution.
  • Other tasks cannot be executed until the blocking function is complete.
  • The Blocking function blocks the thread on which it is executing.

Suspending Function

  • Suspending functions are those, whose execution will not block the execution of the main function.
  • Other tasks can be executed until the blocking function is complete.
  • The Suspending function will not block the thread on which it is executing.

Summary

In summary, the key difference lies in the impact on the program's execution flow. Blocking functions bring the entire program to a halt until the operation is complete while suspending functions allow other tasks to continue while waiting for the completion of an asynchronous operation.

Clone this wiki locally