首页 > 其他 > 详细

Sonar rule for multithread

时间:2014-04-22 20:31:36      阅读:624      评论:0      收藏:0      [点我收藏+]

The purpose of the Thread.run() and Runnable.run() methods is to execute code in a separate, dedicated thread. Calling those methods directly doesn‘t make sense because it causes their code to be executed in the current thread.

To get the expected behavior, call the Thread.start() method instead.

Noncompliant Code Example

bubuko.com,布布扣
Thread myThread = new Thread(runnable);
myThread.run(); // Noncompliant
bubuko.com,布布扣

Compliant Solution

bubuko.com,布布扣
Thread myThread = new Thread(runnable);
myThread.start(); // Compliant
bubuko.com,布布扣

 

Sonar rule for multithread,布布扣,bubuko.com

Sonar rule for multithread

原文:http://www.cnblogs.com/davidwang/p/3680189.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!