{"id":18436164,"url":"https://github.com/mostafa-bashir/syncronization-using-semaphore","last_synced_at":"2026-06-20T20:31:42.217Z","repository":{"id":177944982,"uuid":"436708965","full_name":"mostafa-bashir/Syncronization-using-Semaphore","owner":"mostafa-bashir","description":"This Project shows how to use semaphore to synchronize among many threads","archived":false,"fork":false,"pushed_at":"2021-12-09T18:03:42.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T04:26:39.624Z","etag":null,"topics":["java","operating-system","os","semaphore","syncronization","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/mostafa-bashir.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":"2021-12-09T17:46:38.000Z","updated_at":"2021-12-09T18:03:45.000Z","dependencies_parsed_at":"2024-02-06T07:31:29.039Z","dependency_job_id":null,"html_url":"https://github.com/mostafa-bashir/Syncronization-using-Semaphore","commit_stats":null,"previous_names":["mostafa-bashir/syncronization-using-semaphore"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mostafa-bashir/Syncronization-using-Semaphore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafa-bashir%2FSyncronization-using-Semaphore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafa-bashir%2FSyncronization-using-Semaphore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafa-bashir%2FSyncronization-using-Semaphore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafa-bashir%2FSyncronization-using-Semaphore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mostafa-bashir","download_url":"https://codeload.github.com/mostafa-bashir/Syncronization-using-Semaphore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafa-bashir%2FSyncronization-using-Semaphore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34585195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"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":["java","operating-system","os","semaphore","syncronization","thread"],"created_at":"2024-11-06T06:10:33.809Z","updated_at":"2026-06-20T20:31:42.196Z","avatar_url":"https://github.com/mostafa-bashir.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Synchronization\n# Syncronization-using-Semaphore\n\nIt is required to simulate a limited number of devices connected to a router’s Wi-Fi using\nJava threading and semaphore. Routers can be designed to limit the number of open\nconnections. For example, a Router may wish to have only N connections at any point in\ntime. As soon as N connections are made, the Router will not accept other incoming\nconnections until an existing connection is released. Explain how semaphores can be\nused by a Router to limit the number of concurrent connections\n\nThe following rules should be applied:\n➔ The Wi-Fi number of connected devices is initially empty.\n➔ If a client is logged in (print a message that a client has logged in) and if it can be served\n➔ (means that it can reach the internet), then the client should perform the following\nactivities:\n◆ Connect\n◆ Perform online activity\n◆ Log out\n➔ Note: these actions will be represented by printed messages, such that there is a\nrandom\n➔ waiting time between the printed messages when a client connects, do some online\n➔ activities and logged out.\n➔ If a client arrives and all connections are occupied, it must wait until one of the currently\n➔ available clients finish his service and leave.\n➔ After a client finishes his service, he leave and one of the waiting clients (if exist) will\n➔ connect to the internet.\n\nYou program must contain the following classes:\n1. Router Class: that contains a list of connections and methods to occupy a\nconnection and release a connection.\n2. Semaphore Class: as given the synchronization lab.\n3. Device Class: represent different devices (threads) that can be connected to the\nrouter;\neach device has its own name (i.e. C1) and type (i.e. mobile, pc, tablet...) and it may\nperform three activities: connect, perform online activity and disconnect/logout.\n4. Network Class: this class contains the main method in which the user is asked\nfor two\ninputs:\n● N: max number of connections a router can accept\n● TC: total number of devices that wish to connect).\n● TC lines that contain: name of each device, and its type\n\n Program Output\nYou will print the output logs in a file, which simulates the execution order of the devices threads\nand the printed messages of each device\nNOTE THAT: This is just an example not the only scenario that can be applied.\n Sample Input\nWhat is the number of WI-FI Connections?\n2\nWhat is the number of devices Clients want to connect?\n4\nC1 mobile\nC2 tablet\nC3 pc\nC4 pc\n Sample Output\n- (C1)(mobile)arrived\n- (C2)(tablet)arrived\n- Connection 1: C1 Occupied\n- Connection 2: C2 Occupied\n- C4(pc) arrived and waiting\n- C3(pc)arrived and waiting\n- Connection 1: C1 login\n- Connection 1: C1 performs online activity\n- Connection 2: C2 login\n- Connection 2: C2 performs online activity\n- Connection 1: C1 Logged out\n- Connection 1 : C4 Occupied\n- Connection 1 : C4 log in\n- Connection 1 : C4 performs online activity\n- Connection 2: C2 Logged out\n- Connection 2: C3 Occupied\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostafa-bashir%2Fsyncronization-using-semaphore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostafa-bashir%2Fsyncronization-using-semaphore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostafa-bashir%2Fsyncronization-using-semaphore/lists"}