metrics-core: Fix race condition in InstrumentedThreadFactoryTest.