Mentre stavo leggendo un documento di ricerca sulla concorrenza denominato Software e la Rivoluzione della concorrenza ( versione html ). Mi sono imbattuto in seguenti righe:
Unfortunately, although locks work, they pose serious problems for modern software development. A fundamental problem with locks is that they are not composable. You can’t take two correct lock-based pieces of code, combine them, and know that the result is still correct. Modern software development relies on the ability to compose libraries into larger programs, and so it is a serious difficulty that we cannot build on lock-based components without examining their implementations.
-
Stavo pensando, come Java garantisce la concorrenza componibile o persino c'è un modo per produrre questi scenari.
-
E come possiamo sincronizzare i dati in una o più librerie? Un programmatore può farlo dal suo programma o è in grado di sincronizzare la libreria.
-
Se non è Java, esiste un'altra lingua che usa la concorrenza basata sul blocco e garantisce la concorrenza componibile?
Anche qui viene preso dallo stesso tipo di carta:
There are at least three major problems with synchronized methods. First, they are not appropriate for types whose methods call virtual functions on other objects (e.g., Java’s Vector and .NET’s SyncHashTable), because calling into third-party code while holding a lock opens the possibility of deadlock. Second, synchronized methods can perform too much locking, by acquiring and releasing locks on all object instances, even those never shared across threads (typically the majority). Third, synchronized methods can also perform too little locking, by not preserving atomicity when a program calls multiple methods on an object or on different objects. As a simple example of the latter, consider a banking transfer: account1.Credit(amount); account2.Debit(amount)...
Nota: il documento è stato pubblicato nel settembre 2005