Fix issue 11519 - race in core.thread unit test

https://d.puremagic.com/issues/show_bug.cgi?id=11519