server main loop add own thread
auto shutdown resource