-3

Here my question is: I have a class with 2 methods one is non static synchronized and another is non static non synchronized method. Now 2 threads trying to access same instance of synchronized and non synchronized methods at a time. What will happen if thread one access non static synchronized method first? Can it be possible second thread to access non static non synchronized method of same instance when first thread apply lock on same instance?

Thanks Chandra

  • 6
    if Thread A is accessing non static synchronised, even then any number of threads will be able to access non static non synchronised method – akshaya pandey Dec 19 '17 at 13:48

1 Answers1

0

Yes the second thread can access the non synchronised method. There is no lock needed to access the method and can be done so by any thread. If the methods were both in the below format. 1. Static and synchronized. Will have to wait on the class level lock 2. Non static and synchronized. Will have to wait on object level lock