Fix issue 11519 - race in core.thread unit test