1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | bash-3.2# ./test1original Thread no 0 id = 258 created Threadid id =258(ThreadFunction1), locked and incrementing the count Count (ThreadFunction1) = 1 Thread no 1 id = 515 created Thread no 2 id = 772 created Thread no 3 id = 1029 created Thread no 4 id = 1286 created Thread id 1029 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread no 5 id = 1543 created Thread no 6 id = 1800 created Thread id 1800 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread no 7 id = 2057 created Thread no 8 id = 2314 created Thread no 9 id = 2571 created Thread id 2571 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread 258 going to release lock Thread id = 515(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 2 Thread id 515 going to release lock Thread id = 772(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 3 Thread id 772 going to release lock Thread id = 1286(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 4 Thread id 1286 going to release lock Thread id = 1543(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 5 Thread id 1543 going to release lock Thread id = 2057(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 6 Thread id 2057 going to release lock Thread id = 2314(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 7 Thread id 2314 going to release lock All threads joined, Final count = 7 bash-3.2# |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | STLAB60:../finalCode:> ./test1sys5 Thread no 0 id = 542160384 created Threadid id =542160384(ThreadFunction1), locked and incrementing the count Thread no 1 id = 542195200 created Count (ThreadFunction1) = 1 Thread no 2 id = 542199552 created Thread no 3 id = 542203904 created Thread no 4 id = 542208256 created Thread no 5 id = 542212608 created Thread no 6 id = 542216960 created Thread no 7 id = 542221312 created Thread no 8 id = 542225664 created Thread no 9 id = 542230016 created Thread id 542216960 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread id 542230016 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread id 542203904 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread 542160384 going to release lock Thread id = 542195200(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 2 Thread id 542195200 going to release lock Thread id = 542199552(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 3 Thread id 542199552 going to release lock Thread id = 542221312(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 4 Thread id 542221312 going to release lock Thread id = 542225664(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 5 Thread id 542225664 going to release lock Thread id = 542208256(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 6 Thread id 542208256 going to release lock Thread id = 542212608(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 7 Thread id 542212608 going to release lock All threads joined, Final count = 7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | bash-3.2# ./test1original Thread no 0 id = 258 created Threadid id =258(ThreadFunction1), locked and incrementing the count Count (ThreadFunction1) = 1 Thread no 1 id = 515 created Thread no 2 id = 772 created Thread no 3 id = 1029 created Thread no 4 id = 1286 created Thread id 1029 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread no 5 id = 1543 created Thread no 6 id = 1800 created Thread id 1800 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread no 7 id = 2057 created Thread no 8 id = 2314 created Thread no 9 id = 2571 created Thread id 2571 is in ThreadFunction1, semaphore is already locked and not waiting. Hence will not increment the counter Thread 258 going to release lock Thread id = 515(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 2 Thread id 515 going to release lock Thread id = 772(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 3 Thread id 772 going to release lock Thread id = 1286(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 4 Thread id 1286 going to release lock Thread id = 1543(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 5 Thread id 1543 going to release lock Thread id = 2057(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 6 Thread id 2057 going to release lock Thread id = 2314(ThreadFunction2) , locked and incrementing the count Count (ThreadFunction2) = 7 Thread id 2314 going to release lock All threads joined, Final count = 7 bash-3.2# |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |