Created by: zhaoqin
We split the synch-all threads operation into two synch operations:
- pre-exit synch: synchronize all app threads and ignore client sideline threads
- post-exit synch: synchronize all threads. The pre-exit synch is called before all app thread exit and process exit events. The post-exit synch is called after all the app exit events. By doing so, the sideline thread could be notified and have a chance to exit gracefully before the app process exit event.
Fixes #297