Are there any production-grade implementations of Java Semaphore with possibility to adjust number of permits after semaphore is created?
Are there any production-grade implementations of Java Semaphore with possibility to adjust number of
Share
I can’t quite give you ‘existing production-grade’, but I can give you ‘existing source code’, providing a thin wrapper around an existing production-grade implementation. How’s that?
Essentially, you can extend Java’s Semaphore class to acheive what you want. So, you’re standing on the shoulders of giants.
Item 2, the protected method, explains why you’ll need to extend the Semaphore class.
For a full implementation and better explanation, see this blog entry:
https://web.archive.org/web/20190213082551/http://blog.teamlazerbeez.com/2009/04/20/javas-semaphore-resizing/