It asks:
And third option formally avoids deadlock:Which of the following options avoids a deadlock?
Should I expect such questions from Oracle regarding concurrency?The second thread should call getLocks() only after first thread exits out of it.
This is not necessary. Option 2 works just fine.