Is there a way to determine if the program is synchronized correctly as defined in the JLS?

The Java 7 Language Specification (JLS7-17.4.5) defines a "properly synchronized" program as follows: "A program is correctly synchronized if, and only if, all sequential executions contain no data."

JLS7-17.4.5 also states that:

Without proper synchronization, very strange, confusing, and conflicting behaviors are possible.

So, from a programmer's point of view, it would be very helpful to have a tool to determine if a program is properly synchronized according to the above definition.

Is there such a tool? Googling couldn't find anything. If there is no such tool, can you make one?

+3


source to share


1 answer


FindBugs can find some concurrency bugs (search for "multithreaded correctness" on the list of bugs found ), and there are probably other similar tools, but at the end of some bugs can only be avoided with careful code design and review.

You can also test your classes for concurrency issues, but this is a game of statistics and some errors may not show up depending on OS architecture and CPU etc.



I've heard about the Java concurrency tool but have never used it. The official JSR 166 concurrency list of interests has been mentioned several times .

+4


source







All Articles