{"id":22273839,"url":"https://github.com/geeksloth/lifespan-multithreading","last_synced_at":"2025-03-25T16:42:52.149Z","repository":{"id":180127811,"uuid":"664631497","full_name":"geeksloth/lifespan-multithreading","owner":"geeksloth","description":"Simple Python multithreading examples","archived":false,"fork":false,"pushed_at":"2024-11-11T14:24:12.000Z","size":166,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T14:48:46.120Z","etag":null,"topics":["multi-processing","multi-threading","multiprocessing","multithreading","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","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/geeksloth.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":"2023-07-10T12:04:03.000Z","updated_at":"2024-11-11T14:24:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"e26df7da-1a36-42b3-83e0-2c968e035183","html_url":"https://github.com/geeksloth/lifespan-multithreading","commit_stats":null,"previous_names":["geeksloth/python-multithreading-examples","geeksloth/lifespan-multithreading"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Flifespan-multithreading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Flifespan-multithreading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Flifespan-multithreading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geeksloth%2Flifespan-multithreading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geeksloth","download_url":"https://codeload.github.com/geeksloth/lifespan-multithreading/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245502347,"owners_count":20625956,"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":["multi-processing","multi-threading","multiprocessing","multithreading","python3"],"created_at":"2024-12-03T13:16:31.595Z","updated_at":"2025-03-25T16:42:52.124Z","avatar_url":"https://github.com/geeksloth.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lifespan: Multithreading template\nA simple example of Multithreading programming. This is a template for ones who want to start programming multithreading in Python.\n\n`lifespan.py` result screenshot:\n\n![lifespan result screenshot](static/lifespan.jpg)\n\n\n## Simple example implementation\n```python\nfrom threading import Thread\nfrom time import sleep, process_time, time\n\n\nclass Life (Thread):\n\tdef __init__(self, name, lifespan):\n\t\tThread.__init__(self)\n\t\tself.name = name\n\t\tself.lifespan = lifespan\n\t\tself.age = 0\n\tdef run(self):\n\t\tprint(self.name + \" born\")\n\t\twhile self.age \u003c= self.lifespan:\n\t\t\tsleep(1)\n\t\t\tprint(\"%s: %s\" % (self.name, self.age))\n\t\t\tself.age += 1\n\t\tprint(self.name + \" died\")\n\nplanet = [\n\tLife(\"Mosquito\", 1), #7\n\tLife(\"Housefly\", 4), #28\n\tLife(\"Butterfly\", 2) #14\n\t]\n\nif __name__ == \"__main__\":\n\ttic = process_time()\n\n\tfor life in planet:\n\t\tlife.start()\n\n\tfor life in planet:\n\t\tlife.join()\n\n\ttoc = process_time()\n\tprint(\"main process time: {}\".format(toc-tic))\n\tprint(\"Lifes are dead\")\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeksloth%2Flifespan-multithreading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeeksloth%2Flifespan-multithreading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeksloth%2Flifespan-multithreading/lists"}