If a CriticalSection can acquire (but with a timeout), it can avoid any gridlock.
I googled and Delphi seems to have function which does time out
function MonitorEnter(const AObject: TObject; Timeout: Cardinal = INFINITE): Boolean; How can I do the same in FPC? Dennis