This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Javamex Home Java synchronization Java threads Java profiling Java cryptography Java I/O NIO Java collections Home Synchronization and concurrency wait/notify synchronized keyword Java 5: ConcurrentHashMap Atomic variables Explicit locks Queues Semaphores Search Got a question about Java? Java discussion forum Controlling resources with the Semaphore class in Java 5 A common situation in server applications is that multiple threads compete for resources which are in some way limited in number: either because they are finite, or because (e.g. in the case of database connections) although we could theoretically have a large number, they are expensive to create and hold on to unnecessarily. A typical situation is this: we create a pool which can hold up to some maximum number of resources; at any one time, the pool knows how many resources it has created (in other words, if it is "allowed to create more"); when a thread needs one of the resources, it "requests" one from the pool; when it has finished with it, it...
View Full Document
- Spring '09