Add maximum thread number judgement