pthread hanging

This is a discussion on pthread hanging within the C Programming forums, part of the General Programming Boards category; hi all i am doing a gui application using pthread if i do like this my application is not hanging. ...

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

    pthread hanging

    hi all
    i am doing a gui application using pthread
    if i do like this my application is not hanging.
    Code:
          pthread_t thread;
          gint  iret1;
          iret1=pthread_create( &thread, NULL, write_data, NULL);
    and if i do like this my application is hanging
    Code:
          pthread_t thread;
          gint  iret1;
          iret1=pthread_create( &thread, NULL, write_data, NULL);
          pthread_join( thread, NULL );
    and also what is the deference b/w
    pthread_exit(NULL) and
    pthread_exit(0);

    but i need to join the thread.
    can you help me

    how can i solve this problem

    thank you in advance

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

    hi

    sorry for this.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    pthread_exit(NULL) and
    pthread_exit(0);
    They're both the same.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    136
    Quote Originally Posted by zacs7 View Post
    They're both the same.
    and what about this

    i am doing a gui application using pthread
    if i do like this my application is not hanging.


    pthread_t thread;
    gint iret1;
    iret1=pthread_create( &thread, NULL, write_data, NULL);

    and if i do like this my application is hanging


    pthread_t thread;
    gint iret1;
    iret1=pthread_create( &thread, NULL, write_data, NULL);
    pthread_join( thread, NULL );

    but i need to join the thread.
    can you help me

    how can i solve this problem

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    pthread_join() waits until the target thread is finished before continuing... So of course it's going to lock up. Your going to miss GUI messages, (so your 'dialog' will freeze).

    http://www.opengroup.org/onlinepubs/...read_join.html

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    136
    Quote Originally Posted by zacs7 View Post
    pthread_join() waits until the target thread is finished before continuing... So of course it's going to lock up. Your going to miss GUI messages, (so your 'dialog' will freeze).

    http://www.opengroup.org/onlinepubs/...read_join.html
    but i need to join the thread.(with out hanging)
    is there any way

    thank you in advance

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    join the thread then close the other one you joined with

  8. #8
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Quote Originally Posted by munna_dude View Post
    but i need to join the thread.(with out hanging)
    is there any way
    No. A non-blocking join is a contradiction. Either detach the thread with pthread_detach() so that you no longer have to join it, or join it when its lifetime ends. There is no third option.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pthread question
    By quantt in forum Linux Programming
    Replies: 7
    Last Post: 04-07-2009, 01:21 AM
  2. pthread hanging
    By munna_dude in forum C Programming
    Replies: 1
    Last Post: 05-17-2007, 05:07 AM
  3. The Pthread Hell
    By matott in forum Linux Programming
    Replies: 1
    Last Post: 04-10-2005, 05:59 AM
  4. pthread priority
    By condorx in forum C Programming
    Replies: 2
    Last Post: 04-02-2004, 07:54 PM
  5. pthread create and join problems
    By rotis23 in forum C Programming
    Replies: 1
    Last Post: 10-11-2002, 08:41 AM

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