{"id":13642790,"url":"https://github.com/thanhit95/multi-threading","last_synced_at":"2025-08-28T09:08:33.560Z","repository":{"id":44988609,"uuid":"372698819","full_name":"thanhit95/multi-threading","owner":"thanhit95","description":"Practical multithreading tutorials. Languages supported: C++, Java, C#, Python, Javascript/Nodejs.","archived":false,"fork":false,"pushed_at":"2024-02-27T15:27:56.000Z","size":860,"stargazers_count":168,"open_issues_count":0,"forks_count":47,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-03T11:34:57.945Z","etag":null,"topics":["blocking-queue","concurrency","cpp","csharp","java","javascript","multithreading","mutex","nodejs","producer-consumer","pthread","python","semaphore","synchronization","thread","thread-pool","threading","tutorial","worker"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thanhit95.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-01T04:17:58.000Z","updated_at":"2025-06-02T21:48:41.000Z","dependencies_parsed_at":"2024-08-02T01:16:24.921Z","dependency_job_id":"1b8a9a57-85a8-4c39-a5a4-f2961f1af7dd","html_url":"https://github.com/thanhit95/multi-threading","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thanhit95/multi-threading","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhit95%2Fmulti-threading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhit95%2Fmulti-threading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhit95%2Fmulti-threading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhit95%2Fmulti-threading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thanhit95","download_url":"https://codeload.github.com/thanhit95/multi-threading/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhit95%2Fmulti-threading/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272475096,"owners_count":24940685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blocking-queue","concurrency","cpp","csharp","java","javascript","multithreading","mutex","nodejs","producer-consumer","pthread","python","semaphore","synchronization","thread","thread-pool","threading","tutorial","worker"],"created_at":"2024-08-02T01:01:36.247Z","updated_at":"2025-08-28T09:08:33.534Z","avatar_url":"https://github.com/thanhit95.png","language":"C++","readme":"# MULTIPLE THREADING IN PRACTICE\n\n## DESCRIPTION\n\nThis repo helps you to practise multithreading in a logical sequence, which is divided into several demonstrations.\nPlus, you could apply your learning better by doing exercises.\n\nThe repo consists of two main sections:\n\n- \"demo\" (demostrations).\n- \"exer\" (exercises).\n\nAll the demos (and exers) are really simple, easy to understand, even for difficult terms.\n\nIf you find it helpful, please give my repo a star. Thank you.\n\n\u0026nbsp;\n\n## AUTHOR \u0026 LICENSE\n\nAuthor: Thanh Nguyen\n\n- Email: thanh.it1995@gmail.com\n- Facebook: \u003chttps://www.facebook.com/thanh.it95\u003e\n\nThis repo is licensed under the [3-Clause BSD License](LICENSE.txt).\n\n\u0026nbsp;\n\n## LANGUAGES SUPPORTED\n\n| Directory name | Description                  |\n| -------------- | ---------------------------- |\n| `cpp-std`      | C++20 std threading          |\n| `cpp-pthread`  | C++11 POSIX threading        |\n| `cpp-boost`    | C++98 Boost threading        |\n| `csharp`       | C# 7.3 with Dot Net 6        |\n| `java`         | Java JDK 17                  |\n| `python`       | Python 3.10                  |\n| `js-nodejs`    | Javascript ES2019/Nodejs 18  |\n\nSpecial notes for C++ demos/exers: Please read the specified `readme.md` in corresponding directory.\n\n\u0026nbsp;\n\n## THE NOTES AND ARTICLES\n\nThe notes and articles are the additional resources for the source code, which guides you for better research, step by step. You may consider it the comment/description at the beginning of the source code.\n\n```text\n  ORIGINAL SOURCE CODE FILE                  SOURCE CODE FILE              NOTES AND ARTICLES\n------------------------------        ------------------------------     ----------------------\n|                            |        |                            |     |                    |\n| /* THE COMMENTS... */      |        |                            |     |    THE COMMENTS    |\n|                            |        |                            |     |                    |\n| #include \u003ciostream\u003e        |        | #include \u003ciostream\u003e        |     |                    |\n| using namespace std;       |        | using namespace std;       |     |                    |\n|                            |  ===\u003e  |                            |  +  |                    |\n| int main() {               |        | int main() {               |     |                    |\n|   cout \u003c\u003c \"Hello thread\";  |        |   cout \u003c\u003c \"Hello thread\";  |     |                    |\n|   return 0;                |        |   return 0;                |     |                    |\n| }                          |        | }                          |     |                    |\n|                            |        |                            |     |                    |\n------------------------------        ------------------------------     ----------------------\n```\n\nThere are 2 notes:\n\n- [notes-demos-exercises.md](notes-demos-exercises.md): The notes that go along with original source code.\n- [notes-articles.md](notes-articles.md): Extra helpful notes during my research.\n\n\u0026nbsp;\n\n**For your best result, I strongly recommend that you read [notes-demos-exercises.md](notes-demos-exercises.md) while enjoying source code (demos and exercises).**\n\n\u0026nbsp;\n\n## ROADMAP FOR THE LEARNERS\n\nThis is the roadmap for you, which is composed and researched carefully with all my heart. You should learn in the sequence listed below.\n\n**If you just want to learn the basis to understand the taste of multithreading:**\n\n- Demo: hello, join, pass arg, sleep, list-threads, race-condition, mutex, synchronized-block.\n- Exer: max-div.\n\n**If you are oriented to be a Software Developer:**\n\n- Demo: hello, join, pass arg, sleep, list-threads, terminate, return-value, exec-service, race-condition, mutex, synchronized-block, deadlock, blocking-queue, atomic.\n- Exer: max-div, producer-consumer, product-matrix, data-server.\n\n**If you really want to do an in-depth research:** Learn all!!!\n\n\u0026nbsp;\n\n---\n\n## INTRODUCTION TO MULTITHREADING\n\n### GETTING STARTED\n\nBob sends four messages to Alice: `I love`, `you`, `not`, `her`.\n\nSurprisingly, Alice receives `I love`, `her`, `not`, `you` (That means \"I love her not you\"). So sad!\n\n```text\nTRADITIONAL (ONE THREAD)\n\n    ===========================================\u003e Time\n\n                 Main thread\n    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u003e\n      \"I love\"   \"you\"   \"not\"   \"her\"\n\n\n\nMULTITHREADING (FOUR THREADS)\n\n    ===========================================\u003e Time\n\n    ~~~~~~~~~~~~\u003e\n      \"I love\"\n\n                      ~~~~~~~~~~~~\u003e\n                          \"you\"\n\n              ~~~~~~~~~~~~\u003e\n                  \"not\"\n\n        ~~~~~~~~~~~~\u003e\n            \"her\"\n```\n\nIf you use multithreading or something similar, the context above is truly possible. The reason is that multithreading allows four messages to be sent in parallel, so message order is changed unpredictably when they come to Alice.\n\nIn a traditional simple app, there is only one thread (the \"main thread\"). If you apply multithreading then your app may have multiple threads (including the \"main thread\").\n\nBy learning multithreading:\n\n- You get closer to the operating system.\n- You can understand various terms: concurrency, parallel, asynchronous, synchronization.\n- You have additional knowledge to learn asynchronous programming and parallel programming.\n\nSo, why multithreading?\n\n### WHY MULTITHREADING\n\nMultithreaded programs can improve performance compared to traditional simple programs (which use only a single thread).\n\nMultithreading is used as an underlying technique in various fields:\n\n- Web browsers (Chrome, Edge, Firefox...).\n- Web servers.\n- Graphic editors (Adobe Photoshop, Corel Draw...).\n- Computer games.\n- Database management systems.\n- Networking programming.\n- Video encoders.\n- And more...\n\nBenefits of multithreading:\n\n- Improving application responsiveness.\n  - Any program in which many activities are not dependent upon each other can be redesigned so that each activity is defined as a thread. For example, the user of a multithreaded GUI does not have to wait for one activity to complete before starting another.\n\n- Using multiprocessors efficiently.\n  - Typically, applications that express concurrency requirements with threads need not take into account the number of available processors. The performance of the application improves transparently with additional processors.\n  - Numerical algorithms and applications with a high degree of parallelism, such as matrix multiplications, can run much faster when implemented with threads on a multiprocessor.\n\n- Improving throughput.\n  - Many concurrent compute operations and I/O requests within a single process.\n\n- Program structure simplification.\n  - Threads can be used to simplify the structure of complex applications, such as server-class and multimedia applications. Simple routines can be written for each activity, making complex programs easier to design and code, and more adaptive to a wide variation in user demands.\n\n- Using fewer system resources.\n  - Threads impose minimal impact on system resources. Threads require less overhead to create, maintain, and manage than a traditional process.\n\n- Better communication.\n  - Thread synchronization functions can be used to provide enhanced process-to-process communication.\n  - In addition, sharing large amounts of data through separate threads of execution within the same address space provides extremely high-bandwidth, low-latency communication between separate tasks within an application.\n\n\u0026nbsp;\n\nIf you want to explore more articles, read here: [notes-articles.md](notes-articles.md).\n\n\u0026nbsp;\n\nArticle references:\n\n- [Oracle Documentation Home, Multithreaded Programming Guide, Chapter 1 Covering Multithreading Basics, Benefiting From Multithreading](https://docs.oracle.com/cd/E19455-01/806-5257/6je9h032d/index.html)\n- [Oracle Documentation Home, JDK 1.1 for Solaris Developer's Guide, Chapter 2 Multithreading, Benefits of Multithreading](https://docs.oracle.com/cd/E19455-01/806-3461/6jck06gqj/index.html)\n\n\u0026nbsp;\n\n---\n\n## REFERENCES\n\nAll general references in my repo.\n\nRead here: [references.md](references.md).\n","funding_links":[],"categories":["Programming Language"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanhit95%2Fmulti-threading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanhit95%2Fmulti-threading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanhit95%2Fmulti-threading/lists"}