pthread_create()期间的分段错误

时间:2014-11-05 17:29:46

标签: multithreading pthreads pthread-key-create

好的,所以我试图在一个单独的线程(主线程和我使用pthread_create创建的辅助线程)中对两个文件进行冒泡。我的冒泡排序完美,我测试了几次,所以我没有包括在这里,我的问题是在pthread_create行中给我分段错误。

我有一个冒泡排序功能,可以读取文件并对其进行排序。工作完美。 void * bubblesortCars(char * filename)

问题是这给了我分段错误

pthread_create(&one, NULL, (void*)&bubblesortCars, (char *)&("FirstHalf.txt"));
bubblesortCars("SecondHalf.txt");
pthread_join(one, NULL); 

但是,如果我这样说它会完美地工作,但我不想这样做,因为我希望两个线程同时冒泡排序:

bubblesortCars("SecondHalf.txt");
pthread_create(&one, NULL, (void*)&bubblesortCars, (char *)&("FirstHalf.txt"));
pthread_join(one, NULL); 

0 个答案:

没有答案
相关问题