Per una gestione sensata dei tempi, potresti fare così
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
using namespace std::chrono;
void task(int n, int ms){
while(1){
auto begin = steady_clock::now();
for (int i = 0; i < 100000000; i++); // job
auto end = steady_clock::now();
int duration = duration_cast<milliseconds>(end - begin).count();
cout << "work time task " << n << " = " << duration << endl;
this_thread::sleep_for(milliseconds(ms - duration));
cout << "tick task " << n << endl;
}
}
int main() {
thread t1(task, 1, 2000);
thread t2(task, 2, 3000);
t1.join();
t2.join();
return 0;
}