Ora, non sono sicuro se questa sia una domanda stupida, ti prego di sopportare se è così.Java: cosa, se non altro, è bloccato da metodi sincronizzati oltre all'oggetto a cui appartengono?
Il blocco su un oggetto "ricorsivo", i. e. se due oggetti hanno riferimenti a un terzo oggetto nei loro campi e un thread sta eseguendo un metodo sincronizzato su uno dei due, un altro thread può accedere al terzo oggetto?
// a and b are some objects that implement Runnable
// they both reference the same third object
a.ref = c;
b.ref = c;
// a is run in a thread and processes some data in a loop for a long time
// the method the loop belongs to is declared synchronized
threadA = new Thread(a);
threadA.start();
a.someSyncedMethod(); // this would block ...
b.ref.someOtherSyncedMethod(); // ... but would this?
a.ref.someOtherSyncedMethod(); // ... and how about this?
Non è affatto una domanda stupida, solo una base. Nessun danno nel chiedere di comprendere meglio i fondamenti del linguaggio –
Grazie. Ho sentito che dovrebbe essere ovvio, ma non l'ho ancora capito. –