Java核心知识点学习–线程中的Semaphore学习公共厕所排队策略.docVIP

  • 4
  • 0
  • 约6.82千字
  • 约 8页
  • 2017-05-20 发布于北京
  • 举报

Java核心知识点学习–线程中的Semaphore学习公共厕所排队策略.doc

Java核心知识点学习–线程中的Semaphore学习公共厕所排队策略

1.什么是Semaphore? A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each acquire blocks if necessary until a permit is available, and then takes it. Each release adds a permit, potentially releasing a blocking acquirer. However, no actual permit objects are used; the Semaphore just keeps a count of the number available and acts accordingly. Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource. 上面是官方给予该类的介绍,信号量(Semaphore),有时被称为信号灯,是在多线程环境下使用的一种设施, 它负责协调各个线程, 以保证它们能够正确、合理的使用公共资源。 举个例子,公共厕所只有3个位子,有10个人要上厕所

文档评论(0)

1亿VIP精品文档

相关文档