This article will distinguish Synchronous and Asynchronous. I just want to say forget your Chinese ……
API and callback
While the API receiving the callback remains on the stack, you would expect that the callback had been invoked on each element.
in the same thread
Callback is invoked after a function returns, or at least on another thread’s stack. while the API receiving the callback remains on the stack, the callback may not have been called, since it’s waiting for the connection to complete.
Therefore, if you want to design asynchronous APIs, keep your threads safety.
Factory pattern is a basic pattern in grant software framework. We create object, parent, with common interface to create new type of object. The common interface is a static member-function (static factory method) which creates & returns instances, hiding the details of children.
The following will show a snappiest code of Android Q.
If you use multi-threads to do something at the same time, that is a Synchronization. You need to control threads to avoid Race Condition and Critical Section. mutex and semaphore can solve the critical section. But what’s different?