Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is a mutex?

 
Dave Alkire
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seen the term here but nowhere else yet.
 
K Riaz
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mutual Exclusion. See google for more info.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mutex is a Computer Science term for what Java 2 calls a lock. Since only one thread can hold the lock on an object at one time, a section of code synchronized on an object cannot be entered by a thread while another thread holds the lock on that object. The mechanism for enforcing this rule is called a mutex.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Definitely look up mutex on Google to get a deeper answer, but one example of a mutex is Java's built-in object locking via synchronization. Mutually exclusive when X "has access", Y and Z cannot "gain access." In Java, when a block of code synchronizes on an object, it obtains a mutually exclusive lock on that object. Any other block of code in another thread cannot obtain a lock on the same object until the first block releases the lock.
 
Dave Alkire
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kashif Riaz:
Mutual Exclusion. See google for more info.

Perfect; thanks everyone for the replies! Usually I google for terms instead of posting, but in this case I just wanted to know what y'all, specifically, would say..
Ya see I'm re-reading a section in Sierra's _Sun Certified programmer & Developer for Java 2_, Chapter 9, "Threads", re-doing Exercise 9-2, "Synchronizing a Block of Code".. There was a bit I didn't grok, so I was searching through these JavaRanch forums and kept finding undefined references to that term. But anyway thanks again; all better now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic