
When an include is not surrounded by empty lines, its content is inlined on the same line as the adjacent content. That can lead to broken tags and other display issues. This PR fixes all such includes and introduces a validation step that forbids introducing the same problem again.
46 lines
1.1 KiB
Plaintext
46 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Synchronization can be expensive in terms of time when multiple threads need to pass through the same bottleneck /``++synchronized++`` piece of code.
|
|
|
|
|
|
If you have a piece of code calling a ``++synchronized++`` method once, then it only has to wait its turn to pass through the bottleneck once. But call it in a loop, and your code has to get back in line for the bottleneck over and over.
|
|
|
|
|
|
Instead, it would be better to get into the bottleneck, and then do the looping. I.e. consider refactoring the code to perform the loop inside the ``++synchronized++`` method.
|
|
|
|
|
|
This rule raises an issue when a ``++synchronized++`` method is called in a loop.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
public void doSomething(int max) {
|
|
for (int i = 0; i < max; i++) {
|
|
doSynchronized(i); // Noncompliant
|
|
}
|
|
}
|
|
|
|
public synchronized void doSynchronized(int val) {
|
|
// ...
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|