Fix: Thread sanitizer race.

See the comment in the source. This race should actually not be important, but we fix it anyways for now to make the CI happy.
4 jobs from pure_fork_join in 3 minutes 43 seconds (queued for 1 second)
Status Job ID Name Coverage
  Build
passed #3124
build_cmake

00:45

 
  Test
passed #3125
run_tests

00:42

 
  Sanitizer
passed #3127
run_address_sanitizer

01:19

passed #3126
run_thread_sanitizer

00:55