Skip to content

Instantly share code, notes, and snippets.

@Sam-Belliveau
Last active September 24, 2019 01:34
Show Gist options
  • Select an option

  • Save Sam-Belliveau/44c8aa21f81f315561723f670ad8677d to your computer and use it in GitHub Desktop.

Select an option

Save Sam-Belliveau/44c8aa21f81f315561723f670ad8677d to your computer and use it in GitHub Desktop.
#include <thread>
#include <functional>
#include <cstdio>
std::function<void(void)> ThreadKiller = []()
{
std::thread BabyThread1(ThreadKiller);
volatile std::intmax_t total;
for(volatile std::size_t i = 1; i != 0; ++i)
for(volatile std::size_t j = 2; j < i; ++j)
if(i % j == 0 || j % i == 0) ++total;
else --total;
BabyThread1.join();
};
int main() {
std::fputs("+-----= Starting ThreadHell =-----+\n", stderr);
std::fputs("| ThreadHell will attempt to take |\n", stderr);
std::fputs("| as much CPU time as possible! |\n", stderr);
std::fputs("+---------------------------------+\n", stderr);
ThreadKiller();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment