{"id":17543668,"url":"https://github.com/xkcoding/concurrent-in-action","last_synced_at":"2025-03-29T05:34:07.687Z","repository":{"id":102484565,"uuid":"145721839","full_name":"xkcoding/concurrent-in-action","owner":"xkcoding","description":" 并发编程实践学习","archived":false,"fork":false,"pushed_at":"2020-01-03T07:29:39.000Z","size":16,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T15:55:40.678Z","etag":null,"topics":["concurrency","in-action","java"],"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/xkcoding.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":"2018-08-22T14:37:52.000Z","updated_at":"2021-06-14T18:56:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"32759fd8-7b2d-4eef-ac88-d58b5b374072","html_url":"https://github.com/xkcoding/concurrent-in-action","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xkcoding%2Fconcurrent-in-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xkcoding%2Fconcurrent-in-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xkcoding%2Fconcurrent-in-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xkcoding%2Fconcurrent-in-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xkcoding","download_url":"https://codeload.github.com/xkcoding/concurrent-in-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145013,"owners_count":20730494,"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","in-action","java"],"created_at":"2024-10-21T00:25:12.260Z","updated_at":"2025-03-29T05:34:07.665Z","avatar_url":"https://github.com/xkcoding.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# concurrent-in-action\n并发编程实践学习\n\n## 自定义注解\n\n- `com.xkcoding.concurrentinaction.annotation.Recommend` 用于标记【推荐】的类\n- `com.xkcoding.concurrentinaction.annotation.UnRecommend` 用于标记【不推荐】的类\n- `com.xkcoding.concurrentinaction.annotation.ThreadSafe` 用于标记线程【安全】的类\n- `com.xkcoding.concurrentinaction.annotation.ThreadUnSafe` 用于标记线程【不安全】的类\n\n## 并发测试类\n\n需要进行并发安全测试的类，可以直接继承 `com.xkcoding.concurrentinaction.base.AbstractConcurrentTest` 这个类，重写 `AbstractConcurrentTest#testMethod()` 这个方法，在里面运行调用待测试的方法，然后执行 `AbstractConcurrentTest#execute()` 即可开始并发测试。\n\n示例 `demo`:\n\n```java\npackage com.xkcoding.concurrentinaction.notsafe;\n\nimport com.xkcoding.concurrentinaction.annotation.ThreadUnSafe;\nimport com.xkcoding.concurrentinaction.base.AbstractConcurrentTest;\nimport lombok.extern.slf4j.Slf4j;\n\n/**\n * \u003cp\u003e\n * 并发下int累加\n * \u003c/p\u003e\n *\n * @package: com.xkcoding.concurrentinaction.notsafe\n * @description： 并发下int累加\n * @author: yangkai.shen\n * @date: Created in 2018/8/23 下午11:27\n * @copyright: Copyright (c) 2018\n * @version: V1.0\n * @modified: yangkai.shen\n */\n@ThreadUnSafe\n@Slf4j\npublic class ConcurrentIntAdd extends AbstractConcurrentTest {\n\n\tprivate int count = 0;\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tConcurrentIntAdd test = new ConcurrentIntAdd();\n\t\t// 执行测试方法\n\t\ttest.execute();\n\t\tlog.info(\"count:{}\", test.count);\n\t}\n\n\tprivate void add() {\n\t\tcount++;\n\t}\n\n\t/**\n\t * 测试方法\n\t */\n\t@Override\n\tpublic void testMethod() {\n\t\tadd();\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxkcoding%2Fconcurrent-in-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxkcoding%2Fconcurrent-in-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxkcoding%2Fconcurrent-in-action/lists"}