Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

issues with syncronized methods.  RSS feed

 
Reshma Das
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I completed my assignment. iam working on performance issues. I mave major doubt on synchronized methods.
i have a method
public bookSeats(....) {
lock()
reserve()
unlock()
}
i made the synchronized object lock on lock / unlock and reserve as syncronized method. i read so many articles. they say if a class implements another we should not syncronized the class method
like for example,
public syncronized bookseats() {
lock()
reserve()
unlock()
}
public void lock(){
syncronized(a) {
// lock row
}
}
public void unlock(){
syncronized(a) {
// unlock row
}
}
public syncronized reserve(){}
Iam confused with my readings. can someone explain me where exactly syncronized should be present ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!