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?
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.
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.
Create a Thread by Extending a Thread Class This approach provides more flexibility in handling multiple threads created using available methods in Thread class.
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
yay!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With