Improve maxThread check
Add maxThread security check