main thread  & ai

safely exit main thread

ai send event like player