LINUX.ORG.RU

История изменений

Исправление CatsCantFly, (текущая версия) :

std::vector<std::thread> tds(std::thread::hardware_concurency());
for(auto& t:tds) {
    t = std::thread([](){
        unsigned x = 0;
        while(true) {
           x++;
        }
    });
}
for(auto& t:tds)
    t.join();

Загрузит все ядра на 100%, что еще надо?

Исправление CatsCantFly, :

std::vector<std::thread> tds(std::thread::hardware_concurency());
for(auto& t:tds) {
    t = [](){
        unsigned x = 0;
        while(true) {
           x++;
        }
    };
}
for(auto& t:tds)
    t.join();

Загрузит все ядра на 100%, что еще надо?

Исходная версия CatsCantFly, :

std::vector<std::thread> tds(std::thread::hardware_concurency());
for(auto& t:tds) {
    t = [](){
        unsigned x = 0;
        while(true) {
           x++;
        }
    }
}
for(auto& t:tds)
    t.join();

Загрузит все ядра на 100%, что еще надо?