fix Issue 13416 - dead-lock in FreeBSD suspend handler

- use pthread internal THR_IN_CRITICAL to retry suspend
add regression test
add some explanatory comments
join the spawned thread before leaving unittest block
Merge pull request #1061 from MartinNowak/fix13416

fix Issue 13416 - dead-lock in FreeBSD suspend handler