Thread: Mutex and Multiple Threads Problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    8

    Mutex and Multiple Threads Problem

    I am in school and have been given the problem to use multiple threads and mutex to get two random numbers and in the second thread, produce the greates common factor. And, I need to have this happen 10 times. I have tried and was successful in creating most of the problem but when I attempt to use a mutex, it runs thread 1 (main function) twice before releasing the mutex. Then it runs thread two 7 times before going back to thread 1 for two more times then the last 3 times for thread 2 and finally the remaining times in thread 1. I've tried setting the second parameter in the creation of the mutex to true and thread 2 never runs at all. any help would be appreciated.
    Last edited by roweboats; 06-21-2010 at 12:08 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex, Cond and Thread questions (pthread, linux)
    By thebearot in forum C Programming
    Replies: 14
    Last Post: 04-23-2010, 12:10 PM
  2. Replies: 33
    Last Post: 05-14-2009, 10:15 AM
  3. Multiple Threads
    By NuNn in forum C Programming
    Replies: 3
    Last Post: 03-14-2009, 11:29 PM
  4. Mutex across multiple source files
    By Quasar in forum Linux Programming
    Replies: 7
    Last Post: 12-04-2007, 08:25 AM
  5. WM_COPYDATA and mutex selecting multiple files
    By gh0st in forum Windows Programming
    Replies: 2
    Last Post: 10-27-2006, 02:22 PM