thread creation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting thread creation
# 1  
Old 08-28-2009
thread creation

Code:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *fork_thread(void *ptr );

main()
{
     pthread_t thread1;

     char *message1 = "Thread 1";
     int  iret1;
iret1 = pthread_create( &thread1, NULL, fork_thread, (void*) message1);

exit(0);
}
Void *fork_thread( void *ptr )
{

    int x=10;
    char *message;
    message = (char *) ptr;
     printf("%s \n", message);
       printf(" is %d",x);
}

i am a begginer ,so please don't take it as useless
please find the error in this thread creation

Last edited by vgersh99; 08-28-2009 at 09:52 AM.. Reason: code tags, PLEASE!
# 2  
Old 08-28-2009
  1. Use [code][/code] tags for sources and listings.
  2. C is a high-level language, so things like this should be posted in the appropriate forum
  3. Don't double-post, it's against the rules
  4. What error do you get?
  5. C is a case-sensitive language
# 3  
Old 08-28-2009
error

sorry sir , i am a new user
error: expected ‘=', ‘,', ‘;', ‘asm' or ‘__attribute__' before ‘*' token
this is error is coming while i am executing
# 4  
Old 08-28-2009
Hello Annapurna,

Your problem is the capital _V_ in void. This should be:
Code:
void *fork_thread( void *ptr ) // not Void

There are other problems with your code. May I suggest the following link? POSIX Threads | Loïc OnStage
( In particular, the post: "The main thread" and "Pthreads arguments passing" )

Cheers,
Loïc
--
"Computers are good at following instructions, but not at reading your mind." --
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Programming

Parent Thread Of Child Thread

Parent Thread Of Child Thread Suppose a process creates some threads say threadC and threadD. Later on each of these threads create new child threads say threadC1, threadC2, threadC3 etc. So a tree of threads will get created. Is there any way to find out the parent thread of one such... (1 Reply)
Discussion started by: rupeshkp728
1 Replies

2. Shell Programming and Scripting

thread creation

Void *fork_thread( void *ptr ) i am getting error in this line please help me out (1 Reply)
Discussion started by: annapurna konga
1 Replies

3. Programming

Question on creation of Thread pool

dear sir/madam presently i am in a process of creating a multithread pool using clone() system call in unix with c programming. i am facing some problem ie., i am able create multithread pool and able to keep all the threads in wait state,but when i call kill (afunction revoke a... (6 Replies)
Discussion started by: Radha
6 Replies

4. Solaris

Thread creation in c++

Hi all! Is there a function in c++ to create new threads.I have writen a class "Thread" in which I will be calling this thread function to creat threads. Also is there a function to synchronize threads .I know that we can create objects like semaphores and critical sections to synchronize in... (2 Replies)
Discussion started by: vijlak
2 Replies

5. Programming

How to cancel a thread safely from the initial thread?

how about asynchronous canceling? or with signal? if with signal whether it effects the process? my english so badly :( :( (1 Reply)
Discussion started by: alan.zhao
1 Replies
Login or Register to Ask a Question