Synchronized
From APIDesign
Line 1: | Line 1: | ||
- | Synchronization is getting more and more important in applications and libraries written these days. However synchronization is hard. The primitives available in [[Java]] (or other languages), are ... well, are primitive. Higher level abstractions are available, but still they don't guarantee completely deadlock prone system. This has all been discussed in [[Chapter | + | Synchronization is getting more and more important in applications and libraries written these days. However synchronization is hard. The primitives available in [[Java]] (or other languages), are ... well, are primitive. Higher level abstractions are available, but still they don't guarantee completely deadlock prone system. This has all been discussed in [[Chapter 11]], Runtime Aspects of [[API]]s. |
[[Java Monitor]]s just aren't what they supposed to be (read [[Java Monitor|why]]). Thus I am glad to see that the project [http://projectlombok.org/features/Synchronized.html Lombok's @Synchronized] seems to successfully replace the '''synchronized''' keyword with [[annotation]] (vivat [[TheYearOfAnnotations2009|annotations]]!). | [[Java Monitor]]s just aren't what they supposed to be (read [[Java Monitor|why]]). Thus I am glad to see that the project [http://projectlombok.org/features/Synchronized.html Lombok's @Synchronized] seems to successfully replace the '''synchronized''' keyword with [[annotation]] (vivat [[TheYearOfAnnotations2009|annotations]]!). |
Revision as of 08:47, 7 September 2009
Synchronization is getting more and more important in applications and libraries written these days. However synchronization is hard. The primitives available in Java (or other languages), are ... well, are primitive. Higher level abstractions are available, but still they don't guarantee completely deadlock prone system. This has all been discussed in Chapter 11, Runtime Aspects of APIs.
Java Monitors just aren't what they supposed to be (read why). Thus I am glad to see that the project Lombok's @Synchronized seems to successfully replace the synchronized keyword with annotation (vivat annotations!).
In the name of cluelessness of your Java API users, don't forget to prefer private locks to synchronized methods. Or switch to the beautiful @Synchronized annotation.