Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object Class

 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why wait(),ntify() and notifyAll() methods included in Object Class
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
 
Jacquie Barker
author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has to do with a concept called synchronization. Java is a multi-threaded language, meaning that a program can be written so that multiple processing "threads" can run simultaneously on a multi-processor machine; on a single processor machine, the JVM interleaves the various threads to make them appear to be running simultaneously.
At any rate, if there is a piece of code (a method)or an object that cannot safely be shared by more than one thread at the same time, we can do what is called "syncronizing" on that object or method so that it is GUARANTEED that only one thread can be accessing/affecting it at any given time.
These methods have to do with giving an Object the capability to be synchronized upon.
Hope this helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic