pThread in C++
-
Hallo,
meine Frage, kann ich die "libpthread" auch in C++ benutzen, wenn ja wie.
Vielen Dank vorab.
-
Jo, so wie in C auch.
-
hättest Du vieleicht Beispielcode für mich ?
-
-
//HelloWorld.C // Super Easy Hello world threads program // that anyone can understand #include <pthread.h>//Gimme thread stuff #include <iostream.h> #include <stdlib.h> //O.K. We Need a prototype for a function to pass to //our thread and it must be of form // void *MyThreadFunc(void* ); void* MyThreadFunc(void *arg); //Time for the main function int main(){ //Gimme a thread!! pthread_t aThread;//thanks //Finally lets create the thread and tell it to use MyThreadFunc //as the thread function pthread_create(&aThread, NULL, MyThreadFunc, NULL); //Allows us to wait for the thread to exit pthread_join(aThread, NULL); cout<<"Exiting main\n"; return 0; }
-
Genau das was ich brauche.
vielen Dank Kai !!!
-
-
Jo, ich weiß, hatte das Sample nur von der Seite kopiert.