Thread: Pthread question, multiple arguments

  1. #1
    Registered User
    Join Date
    Jan 2012

    Pthread question, multiple arguments


    i have a thread where i add my function to it. But the problem is i have 3 function more which they have to be added also to the same thread.

    Fore example:
    rv = pthread_create (&tarray[i], NULL, (void *)&function1, (void *)&var;
    My question is how do i add muliple arguments in pthread_create?

  2. #2
    Registered User
    Join Date
    Sep 2007
    You don't. If you need them running concurrently, call pthread_create() 3 times.

    You should also drop the casts. The casting of a function pointer to void* is simply wrong (the type expected is void*(*), not void*); the casting of an object pointer to void* in C is not necessary because it happens automatically. There is an advantage to leaving off casts, too: it allows the compiler to tell you if you're using the wrong type in a lot of cases.

  3. #3
    Join Date
    Dec 2007
    If I'm understanding you correctly, then just call the other functions within function1().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with pthread and multiple arguments
    By user_name_void in forum C Programming
    Replies: 4
    Last Post: 02-17-2010, 03:23 PM
  2. Multiple command line arguments with switches
    By Ene Dene in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2009, 03:28 AM
  3. Sending multiple arguments to function..
    By Zzaacchh in forum C++ Programming
    Replies: 3
    Last Post: 09-06-2008, 03:20 PM
  4. pthread and multiple CPU
    By noelloen in forum C Programming
    Replies: 4
    Last Post: 03-07-2006, 12:00 PM
  5. multiple command line arguments
    By christee in forum C Programming
    Replies: 4
    Last Post: 04-08-2003, 08:35 AM