On master and 0.17 steps to reproduce:

```sh
git checkout bitcoin/master && make distclean
./configure --with-sanitizers=thread CC=clang CXX=clang++
make -j 16 check

boost::thread_group threads;
    for (int i = 0; i < 5; ++i) {
        threads.create_thread(boost::bind(&CScheduler::serviceQueue, &scheduler));
    }
    
    
    int counter1 = 0;
    int counter2 = 0;
    
    
    for (int i = 0; i < 100; ++i) {
        queue1.AddToProcessQueue([i, &counter1]() {
            BOOST_CHECK_EQUAL(i, counter1++);
        });
        queue2.AddToProcessQueue([i, &counter2]() {
            BOOST_CHECK_EQUAL(i, counter2++);
        });
    }
    
    scheduler.stop(true);
    threads.join_all();
    BOOST_CHECK_EQUAL(counter1, 100);
    BOOST_CHECK_EQUAL(counter2, 100);
}
BOOST_AUTO_TEST_SUITE_END()