Fix use of mutex in threaded grep