c++ - Passing parameters to _beginthreadex -


i'm attempting basic parallelisation using _beginthreadex, , passing parameters per example given, won't work.

any ideas?

#include <iostream>  #include <process.h>    void mythread(void *data) {     std::cout << "hello world!";  }  int main() {     _beginthreadex(null, 0, mythread, null, 0, null);      while(true); } 

edit:

why won't passing null argument work? (since function takes no arguments anyway?)

passing null arguments list worked fine _beginthread.

your code has 2 errors in it, neither of related parameter thread function --- null fine that, surmised.

the problems in signature of thread function, , error getting points out. firstly, must __stdcall function, , secondly must return unsigned int. function __cdecl , returns void.

unsigned __stdcall mythread(void *data) {     std::cout << "hello world!";      return 0; } 

should fix problem you.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -