{"id":18026792,"url":"https://github.com/yegor256/threads","last_synced_at":"2025-04-06T12:09:27.032Z","repository":{"id":59158145,"uuid":"154707884","full_name":"yegor256/threads","owner":"yegor256","description":"Ruby Gem to unit-test a piece of code in multiple concurrent threads","archived":false,"fork":false,"pushed_at":"2024-10-15T13:51:41.000Z","size":87,"stargazers_count":35,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-18T03:12:21.343Z","etag":null,"topics":["concurrency","ruby","threading","unit-testing"],"latest_commit_sha":null,"homepage":"https://www.yegor256.com/2018/11/06/ruby-threads.html","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yegor256.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":"2018-10-25T17:02:52.000Z","updated_at":"2024-10-01T15:56:49.000Z","dependencies_parsed_at":"2023-09-23T23:04:23.377Z","dependency_job_id":"2e49e31d-9efa-4221-9167-7263cd848d4b","html_url":"https://github.com/yegor256/threads","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":0.05555555555555558,"last_synced_commit":"6b22069aa66a7389eb6fd224135e626e36aed614"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fthreads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fthreads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fthreads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fthreads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/threads/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478323,"owners_count":20945266,"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","ruby","threading","unit-testing"],"created_at":"2024-10-30T08:08:04.590Z","updated_at":"2025-04-06T12:09:27.012Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","readme":"# Runs Code Block in Many Threads\n\n[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)\n[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/threads)](http://www.rultor.com/p/yegor256/threads)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/threads/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/threads/actions/workflows/rake.yml)\n[![Gem Version](https://badge.fury.io/rb/threads.svg)](http://badge.fury.io/rb/threads)\n[![Maintainability](https://api.codeclimate.com/v1/badges/24fc3acdf781d98b8749/maintainability)](https://codeclimate.com/github/yegor256/threads/maintainability)\n[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/threads/master/frames)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/threads.svg)](https://codecov.io/github/yegor256/threads?branch=master)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/threads)](https://hitsofcode.com/view/github/yegor256/threads)\n\nRead this blog post first: [Do You Test Ruby Code for Thread Safety?][blog]\n\nWhen you need to test your code for thread safety, what do you do?\nThat's right, you just don't test it.\nThat's\n[wrong](https://www.yegor256.com/2018/03/27/how-to-test-thread-safety.html)!\nThis simple gem helps you test your code\nwith just two additional lines of code.\n\nFirst, install it:\n\n```bash\ngem install threads\n```\n\nThen, use it like this, to test your code from multiple\nconcurrently running threads:\n\n```ruby\nrequire 'threads'\nThreads.new(5).assert do |i|\n  puts \"Hello from the thread no.#{i}\"\nend\n```\n\nYou can put whatever you want into the block. The code will be executed\nfrom five threads, concurrently.\nYou can also make sure the code block runs only a specific number of times\nspecifying the argument in the `assert` method (it can't be smaller\nthan the amount of threads):\n\n```ruby\nThreads.new(5).assert(20) do |i, r|\n  puts \"Hello from the thread no.#{i}, repetition no.#{r}\"\nend\n```\n\nYou can also provide a logger, which will print exception backtraces.\nIt has to implement either method `error(msg)` or `puts(msg)`:\n\n```ruby\nThreads.new(5, log: STDOUT).assert do\n  this_code_fails_for_sure\nend\n```\n\nThat's it.\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 2.3+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n\n[blog]: https://www.yegor256.com/2018/11/06/ruby-threads.html\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fthreads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fthreads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fthreads/lists"}