Implemented return values from threads instead of global counter