Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exercise suggestions to help learn multi threading in C# [closed]

I want to get a good grasp of multi-threading in C#. I've read some articles like Joseph Albahari's tutorials that explain the concepts, but as you know, no matter how much you read, most of it becomes rubbish if you don't practice. I need something that has instructive and pragmatic code examples related to real life practices, not some examples that print some lines. Do you have any suggestions?

like image 260
aslisabanci Avatar asked Sep 30 '10 19:09

aslisabanci


People also ask

How can we achieve multi threading?

We can achieve basic functionality of a thread by extending Thread class because it provides some inbuilt methods like yield(), interrupt() etc. that are not available in Runnable interface. Using runnable will give you an object that can be shared amongst multiple threads.

Is multithreading possible in C?

Can we write multithreading programs in C? Unlike Java, multithreading is not supported by the language standard. POSIX Threads (or Pthreads) is a POSIX standard for threads. Implementation of pthread is available with gcc compiler.

Which approach provides more flexibility in handling multiple threads?

Create a Thread by Extending a Thread Class This approach provides more flexibility in handling multiple threads created using available methods in Thread class.


2 Answers

guys guys I think I found a good site: planet-source-code.com. Searching in .Net codes with "thread" keyword seems to return some good examples, like

  • multi threaded folder synchronization
  • multi threaded TCP server
  • background file downloader
  • async. socket
  • P2P file sharing
  • simple POP3 console mail checker and lots of others!

yay!

like image 66
aslisabanci Avatar answered Sep 22 '22 15:09

aslisabanci


Some kind of random number-crunching is a good test for this. I taught myself threading by writing a prime number finder, then breaking my "search" numbers into blocks and using a thread to work through each one.

This let me set some variables on block size, number of threads to use, wait time between firing threads etc. to test how each of these affects performance.

like image 26
cjk Avatar answered Sep 20 '22 15:09

cjk