D
david wolf
The following pthread code cannot compile, I want to know why. Can
somebody give me direction on this?
if I replace the following line of code
status1 = pthread_create(&threadID1, NULL, read, NULL);
with:
status1 = pthread_create(&threadID1, NULL, readerWriter::read, NULL);
It cannot compile either, how to make it to be compiled?
Thanks,
David
----------------cannot compile, want to know why-------
#include <pthread.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
class readerWriter{
public:
void *read(void *ptr);
void createThreads();
};
void *readerWriter::read(void *ptr){
cout<<"read letter "<<endl;
return NULL;
}
void readerWriter::createThreads(){
pthread_t threadID1;
int status1;
//status1 = pthread_create(&threadID1, NULL, readerWriter::read,
NULL);
status1 = pthread_create(&threadID1, NULL, read, NULL);
status1 = pthread_join(threadID1, NULL);
}
int main(){
readerWriter rw;
rw.createThreads();
return 0;
}
somebody give me direction on this?
if I replace the following line of code
status1 = pthread_create(&threadID1, NULL, read, NULL);
with:
status1 = pthread_create(&threadID1, NULL, readerWriter::read, NULL);
It cannot compile either, how to make it to be compiled?
Thanks,
David
----------------cannot compile, want to know why-------
#include <pthread.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
class readerWriter{
public:
void *read(void *ptr);
void createThreads();
};
void *readerWriter::read(void *ptr){
cout<<"read letter "<<endl;
return NULL;
}
void readerWriter::createThreads(){
pthread_t threadID1;
int status1;
//status1 = pthread_create(&threadID1, NULL, readerWriter::read,
NULL);
status1 = pthread_create(&threadID1, NULL, read, NULL);
status1 = pthread_join(threadID1, NULL);
}
int main(){
readerWriter rw;
rw.createThreads();
return 0;
}