Using pthread

This is a discussion on Using pthread within the C Programming forums, part of the General Programming Boards category; We just started programming threads in class, and I am trying to call a function prthread(int argc) from my thread. ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    12

    Using pthread

    We just started programming threads in class, and I am trying to call a function prthread(int argc) from my thread. Here is the code I have:

    Code:
      if (pthread_create(&theThread, NULL,(void *)prThread(argc),
    NULL)!= 0)
      {
          perror("pthread_create");
          exit(1);
      }
    Basically, I don't know how to incorporate variables into functions when I call them in threads. What would the correct syntax be? Thanks.

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    take a look at

    http://www-919.ibm.com/servers/eserv...s/q_refer.html

    the last parameter of pthread_create is used as an argument to the threaded function. i.e.

    Code:
    pthread_create(&theThread, NULL,(void *)prThread,(void *)argc);

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    There's an example in the FAQ
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Here's some more info on threads.
    http://www.cs.cf.ac.uk/Dave/C/

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. Replies: 12
    Last Post: 03-27-2009, 02:36 PM
  3. recv() malfunctioning in a pthread?
    By th3void in forum Networking/Device Communication
    Replies: 7
    Last Post: 11-12-2007, 12:00 PM
  4. The Pthread Hell
    By matott in forum Linux Programming
    Replies: 1
    Last Post: 04-10-2005, 05:59 AM
  5. pthread & LinuxThread
    By Massive in forum Linux Programming
    Replies: 5
    Last Post: 07-08-2003, 06:30 PM

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