I want the AI part to implement in another thread but can't find any idea.

Thanks.