René's URL Explorer Experiment


Title: 关于AQS组件部分的文章的错误 · Issue #645 · Snailclimb/JavaGuide · GitHub

Open Graph Title: 关于AQS组件部分的文章的错误 · Issue #645 · Snailclimb/JavaGuide

X Title: 关于AQS组件部分的文章的错误 · Issue #645 · Snailclimb/JavaGuide

Description: 如上图: 关于文章中的: “ Semaphore(信号量)可以指定多个线程同时访问某个资源。” 这句话在我阅读源码后发现,Semaphore 可以指定一次性可以指定最多 permits个线程执行任务,而不是 : "同时",因为Semaphore它的实现是只要AQS的state>0 == true,那么线程通过不断自旋CAS,就有机会获得执行任务的机会,所以只要在线程自旋期间,state是大于0的,那么任何一个线程都有可能判断成功,而不是多个线程同时成功。。 然后关于这部...

Open Graph Description: 如上图: 关于文章中的: “ Semaphore(信号量)可以指定多个线程同时访问某个资源。” 这句话在我阅读源码后发现,Semaphore 可以指定一次性可以指定最多 permits个线程执行任务,而不是 : "同时",因为Semaphore它的实现是只要AQS的state>0 == true,那么线程通过不断自旋CAS,就有机会获得执行任务的机会,所以只要在线程自旋期间,state是大于...

X Description: 如上图: 关于文章中的: “ Semaphore(信号量)可以指定多个线程同时访问某个资源。” 这句话在我阅读源码后发现,Semaphore 可以指定一次性可以指定最多 permits个线程执行任务,而不是 : "同时",因为Semaphore它的实现是只要AQS的state>0 == true,那么线程通过不断自旋CAS,就有机会获得执行任务的机会,所以只要在线程...

Opengraph URL: https://github.com/Snailclimb/JavaGuide/issues/645

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"关于AQS组件部分的文章的错误","articleBody":"![image](https://user-images.githubusercontent.com/41150022/74838697-ffb05980-535e-11ea-8d86-93fb5927fe9b.png)\r\n\r\n如上图:\r\n关于文章中的: \r\n“ Semaphore(信号量)可以指定多个线程同时访问某个资源。”\r\n这句话在我阅读源码后发现,Semaphore 可以指定一次性可以指定最多 permits个线程执行任务,而不是 :  \"同时\",因为Semaphore它的实现是只要AQS的state\u003e0 == true,那么线程通过不断自旋CAS,就有机会获得执行任务的机会,所以只要在线程自旋期间,state是大于0的,那么任何一个线程都有可能判断成功,而不是多个线程同时成功。。\r\n\r\n然后关于这部分AQS组件的描述个人认为有点模糊不清,所以我在整理后重新组织了下语言:\r\n\r\n##### CountDownLatch\r\nCountDownLatch允许count个线程阻塞在一个地方,直至所有线程的任务都执行完毕。\r\n\r\n\u003eCountDownLatch是共享锁的一种实现,它默认构造AQS的state为count。\r\n\u003e当线程使用countDown方法时,其实使用了tryReleaseShared方法以CAS的操作来减少state,\r\n\u003e直至state为0就代表所有的线程都调用了countDown方法。当调用await方法的时候,如果state不为0,就代表仍然有线程没有调用countDown方法,那么就把已经调用过countDown的线程都放入阻塞队列Park,并自旋CAS判断state == 0,直至最后一个线程调用了countDown,使得state == 0,\r\n\u003e于是阻塞的线程便判断成功,全部往下执行。\r\n\r\n##### Semaphore\r\nSemaphore允许一次性最多(不是同时)permits个线程执行任务。\r\n\r\n\u003eSemaphore与CountDownLatch一样,也是共享锁的一种实现。\r\n\u003e它默认构造AQS的state为permits。当执行任务的线程数量超出permits,那么多余的线程将会被放入阻塞队列Park,并自旋判断state是否大于0。\r\n\u003e只有当state大于0的时候,阻塞的线程才能继续执行,此时先前执行任务的线程继续执行release方法,\r\n\u003erelease方法使得state的变量会加1,那么自旋的线程便会判断成功。\r\n\u003e如此,每次只有最多不超过permits数量的线程能自旋成功,便限制了执行任务线程的数量。\r\n\u003e\r\n\u003e所以这也是我为什么说它可能不是permits个线程同时执行,\r\n\u003e因为只要state\u003e0,线程就有机会执行.\r\n\r\n##### CycliBarrier\r\nCycliBarrier的功能与CountDownLatch相似,但是CountDownLatch的实现是基于AQS的,\r\n而CycliBarrier是基于ReentrantLock(ReentrantLock也属于AQS同步器)和Condition的.\r\n\r\n\u003eCountDownLatch虽然可以令线程阻塞,但是CountDownLatch只能await一次就不能使用了,\r\n\u003e而CycliBarrier有Generation代的概念,一个代,就代表CycliBarrier的一个循环,\r\n\u003e这也是CycliBarrier支持重复await的原因。 \r\n\r\n\r\n\r\n老哥可以选择性的更改下错误的部分。。。\r\n\r\n","author":{"url":"https://github.com/guang19","@type":"Person","name":"guang19"},"datePublished":"2020-02-19T13:41:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/645/JavaGuide/issues/645"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:84d52c32-7075-25cf-ceca-5599dedfb216
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA796:3B780C:B67E95:F7EB98:6A4D576B
html-safe-nonce1cc4bd6b87382583db26b8130be69e9fd51092b0637fd9730a2c43ce35087cc9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzk2OjNCNzgwQzpCNjdFOTU6RjdFQjk4OjZBNEQ1NzZCIiwidmlzaXRvcl9pZCI6IjM1NDYwODEwNTM1NzM5OTkxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac77c02b2099885e92367d6b6e6b230e2fb12592787cf7d80e01b8806aa0bdbe3f
hovercard-subject-tagissue:567577908
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Snailclimb/JavaGuide/645/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e813041691fe5b12848d36b78f42be8a1a859ca80ac98603f31726b175c100d6/Snailclimb/JavaGuide/issues/645
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e813041691fe5b12848d36b78f42be8a1a859ca80ac98603f31726b175c100d6/Snailclimb/JavaGuide/issues/645
og:image:alt如上图: 关于文章中的: “ Semaphore(信号量)可以指定多个线程同时访问某个资源。” 这句话在我阅读源码后发现,Semaphore 可以指定一次性可以指定最多 permits个线程执行任务,而不是 : "同时",因为Semaphore它的实现是只要AQS的state>0 == true,那么线程通过不断自旋CAS,就有机会获得执行任务的机会,所以只要在线程自旋期间,state是大于...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameguang19
hostnamegithub.com
expected-hostnamegithub.com
None2a1443ff9733a3016431263ea73c93d8fe00c195eb4a7670ac30e7848f045441
turbo-cache-controlno-preview
go-importgithub.com/Snailclimb/JavaGuide git https://github.com/Snailclimb/JavaGuide.git
octolytics-dimension-user_id29880145
octolytics-dimension-user_loginSnailclimb
octolytics-dimension-repository_id132464395
octolytics-dimension-repository_nwoSnailclimb/JavaGuide
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id132464395
octolytics-dimension-repository_network_root_nwoSnailclimb/JavaGuide
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3bdd3157ea1f0fd738d408eceeead721acf1dc3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/Snailclimb/JavaGuide/issues/645#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSnailclimb%2FJavaGuide%2Fissues%2F645
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSnailclimb%2FJavaGuide%2Fissues%2F645
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=Snailclimb%2FJavaGuide
Reloadhttps://github.com/Snailclimb/JavaGuide/issues/645
Reloadhttps://github.com/Snailclimb/JavaGuide/issues/645
Reloadhttps://github.com/Snailclimb/JavaGuide/issues/645
Snailclimb https://github.com/Snailclimb
JavaGuidehttps://github.com/Snailclimb/JavaGuide
Notifications https://github.com/login?return_to=%2FSnailclimb%2FJavaGuide
Fork 46.2k https://github.com/login?return_to=%2FSnailclimb%2FJavaGuide
Star 157k https://github.com/login?return_to=%2FSnailclimb%2FJavaGuide
Code https://github.com/Snailclimb/JavaGuide
Issues 57 https://github.com/Snailclimb/JavaGuide/issues
Pull requests 0 https://github.com/Snailclimb/JavaGuide/pulls
Discussions https://github.com/Snailclimb/JavaGuide/discussions
Actions https://github.com/Snailclimb/JavaGuide/actions
Projects https://github.com/Snailclimb/JavaGuide/projects
Security and quality 0 https://github.com/Snailclimb/JavaGuide/security
Insights https://github.com/Snailclimb/JavaGuide/pulse
Code https://github.com/Snailclimb/JavaGuide
Issues https://github.com/Snailclimb/JavaGuide/issues
Pull requests https://github.com/Snailclimb/JavaGuide/pulls
Discussions https://github.com/Snailclimb/JavaGuide/discussions
Actions https://github.com/Snailclimb/JavaGuide/actions
Projects https://github.com/Snailclimb/JavaGuide/projects
Security and quality https://github.com/Snailclimb/JavaGuide/security
Insights https://github.com/Snailclimb/JavaGuide/pulse
关于AQS组件部分的文章的错误https://github.com/Snailclimb/JavaGuide/issues/645#top
doc-bugContent errorhttps://github.com/Snailclimb/JavaGuide/issues?q=state%3Aopen%20label%3A%22doc-bug%22
enhancementNew feature or request or suggestionhttps://github.com/Snailclimb/JavaGuide/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com/guang19
guang19https://github.com/guang19
on Feb 19, 2020https://github.com/Snailclimb/JavaGuide/issues/645#issue-567577908
https://user-images.githubusercontent.com/41150022/74838697-ffb05980-535e-11ea-8d86-93fb5927fe9b.png
doc-bugContent errorhttps://github.com/Snailclimb/JavaGuide/issues?q=state%3Aopen%20label%3A%22doc-bug%22
enhancementNew feature or request or suggestionhttps://github.com/Snailclimb/JavaGuide/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.