Reputation: 1965
I have seen code for summation of an array using threads. In this code a thread is created and an int
data type is returned:
int iret1, iret2;
iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1);
iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2);
I knew that a thread is a child of a process and it uses for executing program. For the executing program memory is needed, and memory is returned by a void*
data type.
What is the logical reason for returning an int
? Can any one explain the actual reason?
Upvotes: 0
Views: 1507
Reputation: 62439
According to man pthread_create
:
Return Value
On success, pthread_create() returns 0; on error, it returns an error number, and the contents of *thread are undefined.
That value simply indicates whether the thread creation was successful or not.
It is not a memory allocation call like malloc
, therefore I don't see why you think it should return a pointer.
Upvotes: 3