Q on synchronised

Reshma Das

Ranch Hand

Posts: 125

posted 14 years ago

iam confused with synchronized methods. can someone give me a brief implementation for it. i have a method public bookSeats(....) { lock() reserve() unlock() } which r the methods to be syncronized ? do i have to make bookseats as syncronised or all the 3 methods to be sync.. pls help.

Steve Granton

Ranch Hand

Posts: 200

posted 14 years ago

Hi, Not meaning to be harsh but I think that before you ask for other people to provide you with code you should spend some time working reading around the subject and working through examples. Try http://developer.java.sun.com and look for tutorials on threads if you haven't already. If you are having problems with the assignment then think of how you would solve the problem and submit it to the forum for comments. People are more than happy to point out if you are are on the wrong track. Thanks, Steve

Reshma Das

Ranch Hand

Posts: 125

posted 14 years ago

i completed my assignment. iam just working on performance issues. i want to c how others did that. 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 syncronized() { a() b() } i was confuse with my reading. i thought someone would help . my data class is extended by 2 other classes. i dont want to assume stuffs & submit my assignment.