Threading
Write a very simple multi threaded program in C#.
1. The program should create two threads that each add data to the same list at the same time. Then after they are both done, print out the entire list.
2. So each thread should loop through 100 times adding the name of the thread doing the work to the list. For example, the first thread should add the string "thread1" to the shared list and the second thread should add the string "thread2" to the same list at the same time. This should result in a somewhat random ordering of the names "thread1" and "thread2" in the shared list that is printed out after both threads complete.
3. When a thread adds a name it should also print out its name and the current count of the list.
4. Make sure that each individual name addition is not interrupted by the other thread.
Questions by musclebai answers by musclebai
Showing Answers 1 - 2 of 2 Answers
Related Answered Questions
Related Open Questions
Threading
1. The program should create two threads that each add data to the same list at the same time. Then after they are both done, print out the entire list.
2. So each thread should loop through 100 times adding the name of the thread doing the work to the list. For example, the first thread should add the string "thread1" to the shared list and the second thread should add the string "thread2" to the same list at the same time. This should result in a somewhat random ordering of the names "thread1" and "thread2" in the shared list that is printed out after both threads complete.
3. When a thread adds a name it should also print out its name and the current count of the list.
4. Make sure that each individual name addition is not interrupted by the other thread.
Profile Answers by musclebai Questions by musclebai
Questions by musclebai answers by musclebai
Related Answered Questions
Related Open Questions