Thread: 2D array of threads?

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

    2D array of threads?

    I have a 2D array of cells and I need each to run its own pthread.

    I have examples where they have created an array of threads e.g. pthread_t tid[CONST]
    and run each thread using a for loop.

    But in order to know which cell in the 2D array each thread belongs to it would be simple to create a 2D array of threads. Each of these cells change variables in other cells so an index is key.

    Is it possible to do something like:

    pthread_t tid[CONST1][CONST2]

    Thanks

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Is pthread_t a data type? If so, you're allowed to make an array of them. If you're allowed to make an array of them, then you're allowed to make a multi-dimensional array of them. I guess you should have just tried it eh?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D array pointer?
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 04-23-2006, 08:16 AM
  2. cannot print out my 2d array correctly! please help
    By dalearyous in forum C++ Programming
    Replies: 5
    Last Post: 04-10-2006, 02:07 AM
  3. Read file in 2D array
    By Chook in forum C Programming
    Replies: 1
    Last Post: 05-08-2005, 12:39 PM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM