Skip to content
Quiz · Multithreading: An Overview · lesson 4 of 10

Quiz — what is wrong with ++counter

What is wrong if two threads run count_up at the same time?

C++
int counter = 0;

void count_up() {
    for (int i = 0; i < 100000; ++i) {
        ++counter;
    }
}