solving threading exercises