Bookmark Topic Watch Topic
  • New Topic

Semaphore (VERY URGENT)

 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
Like in C Language we can implement Semaphore. Can we implement Semaphore in Java? If yes, which API?
Thanks,
Angela
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please note that Angela has posted the same question (arguably more appropriately) in Threads (slap wrists).
- Peter
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the heads up, Peter. This topic is now closed.
 
    Bookmark Topic Watch Topic
  • New Topic