• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Monitor & Semaphore  RSS feed

 
Johnson David
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I have the fallowing doubt

what is the difference between a Monitor and a Semaphore ?

thanks in advanced,

Johnson
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Johnson David:
HI,

I have the fallowing doubt

what is the difference between a Monitor and a Semaphore ?

thanks in advanced,

Johnson


These are just different terminologies. A Monitor is best regarded as a generic term for a synchronization lock, although I have seen cases where it is used to refer to the condition variable functionality too. (The condition variable is the wait()/notify() support of the object class)

A semaphore is also a generic term for a synchronization lock -- although it is not used very often in this regard. Most likely, when this term is used, it is used to refer to a counting semaphore, which is a lock that keeps track of a count of permits. With Java 5.0, counting semaphore support was added with the Semaphore class.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!