File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Semaphore (VERY URGENT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Semaphore (VERY URGENT)

Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Like in C Language we can implement Semaphore. Can we implement Semaphore in Java? If yes, which API?
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
There is no API in the core java libraries for semaphores. You can build your own from the syncrhonization primatives in java if you wish.
Also, Doug Lea has written a library that does this already.

SCJP 1.4
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Depending on what you want to do, many of the uses of semaphores are easier to implement in Java using the synchronized keyword. If you're already ruled that out for your application, then by all means use Doug Lea's libraries, which offer a far wider assortment of control mechanisms.

"I'm not back." - Bill Harding, Twister
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Please note that Angela has posted the same question (arguably more appropriately) in Threads (slap wrists).
- Peter
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Thanks for the heads up, Peter. This topic is now closed.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
I agree. Here's the link:
subject: Semaphore (VERY URGENT)
It's not a secret anymore!