to write threads

This is a discussion on to write threads within the C Programming forums, part of the General Programming Boards category; hi all i have a doubt. i wrote a program using threads. i used threads like this Code: void one() ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    136

    to write threads

    hi all
    i have a doubt.
    i wrote a program using threads.
    i used threads like this
    Code:
    void one()
    {
          pthread_t thread;
          gint  iret1;
          iret1=pthread_create( &thread, NULL, two, NULL);
    }
    void two()
    {
    printf("enterd in to thread \n");
    three();
    pthread_exit(0);
    }
    
    void three()
    {
    printf("hiiiiiiii \n");
    }
    can you tell is this wright way to use threads.


    help me thank you in advance

  2. #2
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    Well, this certainly produces a result but maybe not what intend to do. You might look again at the definition of a thread and first reason if you really really really NEED a thread and how the problem can be solved by several threads running in parallel.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Yet another n00b in pthreads ...
    By dimis in forum C++ Programming
    Replies: 14
    Last Post: 04-07-2008, 01:43 AM
  2. Reroute where programs write to
    By willc0de4food in forum C Programming
    Replies: 7
    Last Post: 09-21-2005, 05:48 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Threads terminate when parent process does?
    By BigDaddyDrew in forum Windows Programming
    Replies: 1
    Last Post: 04-21-2004, 05:32 PM
  5. Problem : Threads WILL NOT DIE!!
    By hanhao in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2004, 02:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21