Synchronize printing and resource passing.

Deadlock still possible.