2D array of threads?

This is a discussion on 2D array of threads? within the C Programming forums, part of the General Programming Boards category; I have a 2D array of cells and I need each to run its own pthread. I have examples where ...

  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
    32,821
    We did this already!
    passing a structure to a pthread
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 09: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, 03:07 AM
  3. Read file in 2D array
    By Chook in forum C Programming
    Replies: 1
    Last Post: 05-08-2005, 01:39 PM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 05:15 AM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

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