{"id":24794154,"url":"https://github.com/shubhamv108/concurrency-multithreading","last_synced_at":"2025-03-24T17:47:47.737Z","repository":{"id":186316109,"uuid":"299904242","full_name":"shubhamv108/concurrency-multithreading","owner":"shubhamv108","description":"Sample examples of multi-threaded code in Java.","archived":false,"fork":false,"pushed_at":"2025-01-21T17:15:01.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-29T22:44:46.257Z","etag":null,"topics":["concurrency","consumer-producer","context-switching","count-down-latch","cyclic-barrier","multi-threading","mutex","mutex-synchronisation","semaphore","thread"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shubhamv108.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-09-30T11:59:57.000Z","updated_at":"2025-01-21T17:15:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"8169d426-04bc-423a-aac9-58f5125db9a4","html_url":"https://github.com/shubhamv108/concurrency-multithreading","commit_stats":null,"previous_names":["shubhamv108/concurrency-multithreading"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shubhamv108%2Fconcurrency-multithreading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shubhamv108%2Fconcurrency-multithreading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shubhamv108%2Fconcurrency-multithreading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shubhamv108%2Fconcurrency-multithreading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shubhamv108","download_url":"https://codeload.github.com/shubhamv108/concurrency-multithreading/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245321522,"owners_count":20596360,"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","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":["concurrency","consumer-producer","context-switching","count-down-latch","cyclic-barrier","multi-threading","mutex","mutex-synchronisation","semaphore","thread"],"created_at":"2025-01-29T22:34:20.126Z","updated_at":"2025-03-24T17:47:47.704Z","avatar_url":"https://github.com/shubhamv108.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Thread\n- Lightweight process responsible for executing a task\n\n#### Process vs Thread\n- Process is isolated. | Threads share memory.\n- Process switching uses interface in operating system | Thread switching does not require to call a operating system and cause an interrupt to the kernel.\n- PCB, Stack, Address space  | PCB, TCB, Stack, common Address space\n- A thread is a path of execution within a process. A process can contain multiple threads. \n- more time for context switching. | less time for context switching.\n\n#### PCB\n- Process Id\n- Process state\n- Process priority\n- Accounting Information\n- Program Counter\n- CPU Register\n- PCB Pointers\n- .....\n\n\n\n#### TCB\n- Thread ID\n- Thread State\n- CPU Information\n- Program Counter\n- Register contents\n- Thread Priority\n- Pointer to process that created this thread\n- Pointers to other threads that were created by this thread\n\n** https://www.geeksforgeeks.org/thread-control-block-in-operating-system/?ref=rp\n\n\n#### Address Space\nvalid addresses in memory that are available for process.\n\n\n\n#### Process in Java\nhttps://www.geeksforgeeks.org/java-lang-process-class-java/\n\n\n\n#### Links\n- https://www.geeksforgeeks.org/thread-models-in-operating-system/?ref=rp\n- https://www.geeksforgeeks.org/thread-in-operating-system/?ref=rp\n- https://www.geeksforgeeks.org/mutex-lock-for-linux-thread-synchronization/?ref=rp\n- https://www.geeksforgeeks.org/kernel-in-operating-system/?ref=rp\n- https://www.geeksforgeeks.org/difference-between-user-level-thread-and-kernel-level-thread/?ref=rp\n- https://www.geeksforgeeks.org/difference-between-process-and-kernel-thread/?ref=rp\n- https://www.geeksforgeeks.org/difference-between-operating-system-and-kernel/?ref=rp\n\n\n#### Concurrency vs Parallelism (ToDo)\n##### Parallel\n- multiple things at same time\n- genuine simultaneous execution\n##### Concurrency\n- multiple things together but not same time \n- appearance of simultaneous execution (by interleaving of processes in time)\n\n#### False Sharing\n- https://dzone.com/articles/what-false-sharing-is-and-how-jvm-prevents-it\n- https://medium.com/@rukavitsya/what-is-false-sharing-and-how-jvm-prevents-it-82a4ed27da84\n\n## Critical Section\na piece of code that accesses a shared resource, usually a variable or data structure.\n\n## Race Condition\na software error that occurs when multiple threads access a shared resource\n\n## Intermediate Program\n- Consists of 1 or * race conditions;\n- the o/p of program is not \u003cb\u003edeterministic\u003c/b\u003e \u0026 varies from run to run.\n\n## Mutual Exclusion\nno two processes can exist in the critical section at any given point of time\n\n## InterProcess Communication\n- coordinate and synchronize between processes \n- ways\n  1. Pipes\n  2. Signals\n  3. Buffers: Message queues etc\n  4. Sockets\n\n## Shared memory\n- Common memory region from PCB\n\n## AssemblerInstructions\n#### ldsub\nload/store unsigned instruction byte (locked version of atomic exchange)\n#### xchg\natomic exchange","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshubhamv108%2Fconcurrency-multithreading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshubhamv108%2Fconcurrency-multithreading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshubhamv108%2Fconcurrency-multithreading/lists"}