Is there any way that allow us to achieve asynchronous operation other than callback function?

63 views Asked by At

The main thread tells the system to do something, and registers a callback function handler(). Then the main thread continue to do some other work. When the task is finished, the system will call handler(). The handler() and the main thread can run concurrently. This is what I know about callback function.

But I have two questions:

  1. In the case above, the handler() will respond to the result of the task and finish the rest of the work. What if we want the main thread to respond to the completion of the task but still can do some other work before the task is completed, can we do that?

  2. Is there any other techniques that we could use to achieve asynchronous operations other than callback function?

Thank you for your help. :)

0

There are 0 answers