rspec/rules/S3049/java/rule.adoc

43 lines
984 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
``++Thread.yield++`` is intended to hint to the processor that the current thread is willing to suspended in favor of another thread. Unfortunately, it doesn't have the same results across platforms, thus marring the cross-platform compatibility of any application that uses it.
=== 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
----
public void doSomething() {
// ...
Thread.yield(); // Noncompliant
// ...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this use of "Thread.yield".
'''
== Comments And Links
(visible only on this page)
=== on 11 Jun 2015, 19:43:14 Ann Campbell wrote:
CodePro: Disallow Yield Usage
=== on 16 Jun 2015, 17:08:58 Nicolas Peru wrote:
Looks good
=== on 16 Aug 2016, 16:52:57 Ann Campbell wrote:
Note to self: \http://stackoverflow.com/questions/38978112/thread-yield-still-a-cross-platform-minefield
endif::env-github,rspecator-view[]