wood burning stoves 2.0*
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
Author

Semaphore (VERY URGENT)

Angela D'souza
Ranch Hand

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

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.
http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html


Rob
SCJP 1.4
Jim Yingst
Wanderer
Sheriff

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
author
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
Sheriff

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: http://aspose.com/file-tools
 
subject: Semaphore (VERY URGENT)