As an added question, how many possible outputs exist if the threads lock on the same object ? Figuring that out will help you at the exam and at work.
if threads lock on same object,then also there can be many outputs as
JVM can choose any of the threads to run first i.e.
main
thread rba
thread rbb
if thread rba runs first ,then rbb cannot run as they both lock on same object but JVM can start main thread and stop rba in between and run it's code i.e.
then ,JVM again chooses rba and executes its statement from where it was stopped.