C ++ Spawning线程

时间:2012-06-03 12:20:02

标签: c++ multithreading posix

你好,我需要一个正确生成线程的手,我似乎无法正确的语法。 这是我的代码......

// Spawn a thread--------------------------------------------------#    
    pthread_t thread1;  // thread object
    int rc1;

    if( (rc1=pthread_create( &thread1, NULL, spellCheck, NULL)) )
    {
        cout << "Thread creation failed: " << rc1 << endl;
    }

    pthread_join( thread1, NULL);

功能定义

void spellCheck(vector<string> * fileRead, list<string> * incorrectWord, vector<string> * correctWord)
{   

头文件

void spellCheck(vector<string> *fileRead, list<string> *incorrectWord, vector<string> *correctWord);

任何帮助都会非常感激:)

我的错误:

server.cpp:142: error: invalid conversion from 'void ()(std::vector<std:................. initializing argument 3 of 'int pthread_create(pthread_t, const pthread_attr_t*, void* ()(void), void*)'

1 个答案:

答案 0 :(得分:5)

我可能在这里错了,但我认为你实现并传递给pthread_create()的线程函数只能有一个(void *)输入参数