Attemped to prevent deadlock when blocking in different threads