I am programming multi-thread codes in .NET
I tried to #include <pthread.h>
But complier reproted
Cannot open include file: 'pthread.h': No such file or directory.
What happened? How can I implement multi-thread in .NET?
I am programming multi-thread codes in .NET
I tried to #include <pthread.h>
But complier reproted
Cannot open include file: 'pthread.h': No such file or directory.
What happened? How can I implement multi-thread in .NET?
Are you sure that the include directory has the header file in question?
It probably doesn't. pthread.h is the main include of the POSIX thread library, which doesn't exist by default on Windows.
You have three options.
1) Use the threading functions of the Win32 API: CreateThread (_beginthreadex if you're using the CRT or C++, i.e. always) is a good starting point.
2) Use a pthread library implemented on top of the Win32 API. There are one or two good ones out there.
3) Use an entirely different, cross-platform threading library. Boost.Thread is the most obvious choice, and generally a very good choice in C++ because of its good support for C++ idioms. In addition, toolkits like Qt and wxWidgets have threading libraries.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Thank you, CornedBee.
For the option (1), what class should i use. Cthread?
Huh? What class? The Win32 API has no classes.
Are you using MFC? The .Net framework?
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
windows.h
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law