rspec/rules/S3048/java/rule.adoc

51 lines
869 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Naming a thread won't make it run faster or more reliably, but it will make it easier to deal with if you need to debug the application.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
Thread t1 = new Thread(new Runnable() {
// ...
};
t1.start(); // Noncompliant; this thread wasn't named
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,java]
2021-04-28 16:49:39 +02:00
----
Thread t1 = new Thread(new Runnable() {
// ...
};
t1.setName("t1");
t1.start();
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Name this thread to ease debugging and profiling.
'''
== Comments And Links
(visible only on this page)
=== on 11 Jun 2015, 19:37:06 Ann Campbell wrote:
CodePro: Disallow Unnamed Thread Usage
=== on 16 Jun 2015, 17:09:38 Nicolas Peru wrote:
Looks good.
endif::env-github,rspecator-view[]