Classic concurrency/deadlock problem