Avoid deadlock risk

Pull request for #1043

This shows my first position where i often run on a deadlock with my application. would be nice if you take it in master. until there i have use some workarounds, but would be nice without them. tests would be run faster.

I have no idea to reproduce the second deadlock position. maybe later i will find a way und create a fix.