Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

C# Multithreading Lab

A step-by-step learning repository for building a deep understanding of multithreading, concurrency, parallelism, async/await, synchronization, producer/consumer patterns, Channels, benchmarking, and testing in C#/.NET.

Main goal

This repository is not just a collection of examples. It is a structured learning path.

For every topic you will:

  1. Implement a naive version.
  2. Observe the problem.
  3. Implement a better version.
  4. Write correctness tests.
  5. Write stress tests where useful.
  6. Benchmark alternatives.
  7. Document what you learned.

Repository structure

csharp-multithreading-lab/
├── docs/                         Learning documentation
├── src/
│   ├── MultithreadingLab.Core/    Interfaces and reusable implementations
│   ├── MultithreadingLab.Playground/ Console experiments
│   └── MultithreadingLab.App/     Final job processor app
├── tests/
│   ├── MultithreadingLab.Tests/   Unit tests
│   └── MultithreadingLab.StressTests/ Stress/concurrency tests
├── benchmarks/
│   └── MultithreadingLab.Benchmarks/
└── .github/
    ├── workflows/
    └── ISSUE_TEMPLATE/

Suggested setup

dotnet restore
dotnet build
dotnet test
dotnet run --project src/MultithreadingLab.Playground
dotnet run -c Release --project benchmarks/MultithreadingLab.Benchmarks

Learning roadmap

Start here:

  1. Roadmap
  2. Thread vs Task
  3. ThreadPool
  4. Race Conditions
  5. Locking
  6. Async/Await
  7. Parallelism
  8. Producer/Consumer
  9. Channels
  10. Cancellation and Timeouts
  11. Deadlocks and Starvation
  12. Performance Guidelines
  13. Final Project

Definition of done for each step

Each task is complete only when:

  • The implementation is finished.
  • Unit tests pass.
  • Stress tests are added if the topic involves shared state.
  • A benchmark exists if there is a meaningful performance comparison.
  • The documentation page contains:
    • Problem
    • Naive implementation
    • Improved implementation
    • Trade-offs
    • Benchmark notes
    • Key takeaways

Branching suggestion

Use one branch per topic:

git checkout -b 001-thread-vs-task
git checkout -b 002-threadpool
git checkout -b 003-race-conditions

Recommended issue order

The GitHub issue templates are in .github/ISSUE_TEMPLATE.

You can create one issue per step using the task descriptions from docs/00-roadmap.md.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages