Wait thread processing in the main thread, otherwise the whole process would exit!