是否有一个工具来确定程序是否“正确同步”如JLS中定义的? [英] Is there a tool to determine whether a program is "correctly synchronized" as defined in JLS?

查看:168
本文介绍了是否有一个工具来确定程序是否“正确同步”如JLS中定义的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java语言规范7(JLS7-17.4.5)定义了一个正确同步的程序,如下所示:当且仅当所有顺序一致的执行都没有数据竞争时,程序才能正确同步。

The Java Language Specification 7 (JLS7-17.4.5) defines a "correctly synchronized" program like this: "A program is correctly synchronized if and only if all sequentially consistent executions are free of data races".

JLS7-17.4.5还声明:

JLS7-17.4.5 also states that:


没有正确的同步,很奇怪,和反直觉行为是可能的。

Without correct synchronization, very strange, confusing and counterintuitive behaviors are possible.

因此,从程序员的角度来看,使用一个工具来确定是否根据上述定义,程序被正确同步。

So, from a programmer's point of view, it would be very useful to have a tool to determine whether a program is "correctly synchronized" according the the above definition.

有没有这样的工具?我找不到任何由谷歌在它。如果没有这样的工具,是否可以创建一个?

Is there such a tool? I could not find anything by Googling on it. If there is no such tool, would it be possible to make one?

推荐答案

FindBugs 可以找到一些并发性错误(在检测到的错误列表),并且可能有其他类似的工具,但最终,一些错误只能通过细致的代码设计和审查来避免。

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

您还可以测试类的并发问题,但它是一个统计的游戏,一些错误可能永远不会显示取决于操作系统/ CPU架构等。

You can also test your classes for concurrency issues, but it is a game of statistics and some bugs might never show up depending on OS/CPU architecture etc.

我听说过 Java并发酷刑工具,但从未使用过它。在官方的 JSR 166并发兴趣列表

I have heard about the Java concurrency torture tool, but never used it. It has been mentioned several times on the official JSR 166 Concurrency Interest list.

这篇关于是否有一个工具来确定程序是否“正确同步”如JLS中定义的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆