Fix some data races in tst_qthreadpool.

Detected by helgrind.

Change-Id: I5f73a62610b4bdc7f26629f3dcf7b11467897a5c
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>