Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Threading on both Windows and Linux

I have seen tutorials on the internet for making multithreaded applications in C++ on Windows, and other tutorials for doing the same on Linux, but not for both at the same time. Are there functions that would work even if they were compiled on either Linux or Windows?

like image 831
Langley Avatar asked Nov 29 '22 04:11

Langley


2 Answers

You would need to use a library which contains an implementation for both pthread on Linux and the Win32 threading library on Windows (CreateThread and friends).

Boost thread is a popular choice which abstracts the system away.

like image 95
Yann Ramin Avatar answered Dec 05 '22 11:12

Yann Ramin


You can use POSIX threads and use this library to get pthreads on Windows.

http://sourceware.org/pthreads-win32/

(This is probably only a good option if you're already very used to doing threading on a POSIX system...)

like image 21
Tim Coker Avatar answered Dec 05 '22 10:12

Tim Coker