Blocking IO Vs Non-blocking IO

Everything that's not CPU is called an IO.

Blocking IO

When there is a call to thread, the cpu will wait and sleep the thread until the IO result return.

Doing this is very bad for single-threaded environment.

Non-blocking IO

Implement an Event Queue to store the call back instead. So the code syntax will look like this

http.get("google.com").success((response) -> {
	processRespose(response)
})

In this case, the function execute and return immediately, there is no wait happens. Therefore we can still using that single-threaded to execute different part of code.