Skip to content

Instantly share code, notes, and snippets.

@nikcleju
Created March 8, 2022 17:33
Show Gist options
  • Save nikcleju/15875bcfe366ca17be6518c3e8ed593f to your computer and use it in GitHub Desktop.
Save nikcleju/15875bcfe366ca17be6518c3e8ed593f to your computer and use it in GitHub Desktop.

Revisions

  1. nikcleju created this gist Mar 8, 2022.
    22 changes: 22 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #include <iostream>
    #include <thread>
    #include <chrono>
    #include "xcpp/xdisplay.hpp"

    void threadFunc()
    {
    using namespace std::chrono_literals;
    int repeat = 30;
    for (int i=0; i < repeat; i++)
    {
    std::cout << "(Keep alive "<< i+1 << "/" << repeat << ")" << std::endl << std::flush;
    // Sleep this thread for 300 Seconds
    std::this_thread::sleep_for(290s); //300000ms = 300s = 5 min
    //xcpp::clear_output(true); // prevents flickering
    }
    std::cout << "(Keep alive finished)";
    }

    //threadFunc()
    std::thread th(&threadFunc);
    th.detach();