yggdrasil/test.cpp

22 lines
630 B
C++
Raw Normal View History

2024-11-15 20:37:59 +02:00
#include <iostream>
2024-11-17 23:32:07 +02:00
#include <cerrno>
#include <fcntl.h>
2024-11-26 22:59:23 +02:00
#include <thread>
2024-11-15 20:37:59 +02:00
int main() {
2024-11-26 22:59:23 +02:00
std::cout << "Spawning a thread" << std::endl;
std::cout << "Main thread is: " << std::this_thread::get_id() << std::endl;
std::cout << "Hardware concurrency: " << std::thread::hardware_concurrency() << std::endl;
2024-11-15 20:37:59 +02:00
2024-11-26 22:59:23 +02:00
std::thread t1([]() {
std::cout << "Hello from a thread!!!" << std::endl;
std::cout << "This is thread: " << std::this_thread::get_id() << std::endl;
});
2024-11-17 23:32:07 +02:00
2024-11-26 22:59:23 +02:00
std::cout << "Waiting for a thread" << std::endl;
t1.join();
std::cout << "Thread finished" << std::endl;
2024-11-17 23:32:07 +02:00
2024-11-15 20:37:59 +02:00
return 0;
}