36 lines
1.8 KiB
Plaintext
36 lines
1.8 KiB
Plaintext
=== on 10 Oct 2014, 11:14:05 Freddy Mallet wrote:
|
|
My 2 cents @Ann, I would:
|
|
|
|
* Replace the tag "performance" by "bug"
|
|
* Replace the category "Efficiency" by "Reliability"
|
|
|
|
Moreover, I would recommend the following remediation action:
|
|
|
|
* Make MyRunner directly implements the Runnable interface
|
|
* Then create and launch a thread like this : "new Thread(new MyRunner()).start()"
|
|
|
|
=== on 10 Oct 2014, 18:25:43 Ann Campbell wrote:
|
|
\[~freddy.mallet] I've implemented your first 2 suggestions, but the last 2 confused me.
|
|
|
|
|
|
I think the emphasis of this rule was itself confused. The title addressed the ``++Runnable++`` but the description was about the class that created an instance of a vacuous ``++Runnable++``. I've updated the description and code samples to move the emphasis to the empty ``++Runnable++``. Please let me know if you feel changes are still needed.
|
|
|
|
=== on 11 Oct 2014, 12:23:51 Freddy Mallet wrote:
|
|
\[~ann.campbell.2], there are two ways to implement a thread :
|
|
|
|
____
|
|
One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started
|
|
|
|
The other way to create a thread is to declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated, passed as an argument when creating Thread, and started
|
|
|
|
____
|
|
|
|
In term of separation of concerns, the second approach is definitely the best one. Moreover with this second approach it's simply impossible to forget to implement the run() method whereas when extending the Thread class, nothing compel you to override the Thread.run() method.
|
|
|
|
=== on 14 Oct 2014, 20:25:42 Freddy Mallet wrote:
|
|
I'm sorry @Ann, but I'm going to rework this rule.
|
|
|
|
=== on 12 Jun 2015, 15:18:36 Ann Campbell wrote:
|
|
CodePro: No Run Method
|
|
|