我有以下主程序:
int main(int argc, char** argv) {
/*checkParameters(argc,argv);*/
if (pthread_create(&supplierid, NULL, &supplier, NULL) != 0);
error("ERROR creating supply threads \n");
}
void *supplier () {
printf("hello? \n");
while (timeremaining >= 0) {
printf("\n the stock is %d" , stock);
printf("\n the supply ies %d", supply);
timeremaining--;
if (stock + supply > cap_max)
stock = cap_max;
else
stock = stock + supply;
sleep(0.1);
}
exit(EXIT_SUCCESS);
}
好吧,95% 的时间我运行这个程序我得到错误创建供应线程。它从不打印你好。这是没有意义的。它只有 1 个线程。
提前致谢。