Added locks to send channels and changed some threads to processes