当我运行 pmd 检查时,我的代码出现避免线程组错误,但我不明白为什么。谁能给我解释一下吗?
Timestamp currentTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
这是 pmd 日志:
<violation beginline="40" endline="40" begincolumn="36" endcolumn="53" rule="AvoidThreadGroup" ruleset="Basic Rules" package="com" class="Route" externalInfoUrl="http://pmd.sourceforge.net/rules/basic.html#AvoidThreadGroup" priority="3">
Avoid using java.lang.ThreadGroup; it is not thread safe
最佳答案
没关系,我已经通过了 pmd 检查。我不知道为什么,但我用这个替换了该行并且它起作用了:
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
关于java - 避免在时间戳上使用 java.lang.ThreadGroup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25550489/