finished part-D

implemented "mutex_lock" on the count function