• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

object locking

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i could not get the locking concept clearly. please somone explain me by taking this prg as example
until synchNonStat1 method completes , thread t1 can't enter into synchNonStat2 method. but in between these two,
1. is there any chance of calling nonsynchNonstat1 method?
2. is there any chance of invoking nonsynchNonstat2 method while executing the nonsynchNonstat1 method

 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to use the example you showed? It's not going to show anything about locking/synchronization because you're only using one thread. The java tutorials have a nice section about synchronization: here.
 
rama rajesh
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My knowledge on this.

A thread can't enter any of static synch methods of a class, if any other thread is executing the static synchro method of class(Locking on class will be happened)
if a thread entered the nonstatic synchr method of a object, any other thread can't enter the any of the nonstatic synch method of that object(object locking will be happened).

 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need the second thread creation (t2) back in for this example to be worth comment.
 
reply
    Bookmark Topic Watch Topic
  • New Topic