run() is called on a Thread, which runs the work on the calling thread
What it finds
Thread { work() }.run() calls the thread's task directly on the current thread; no new thread starts. start() was meant.
Reported when the receiver is a Thread(...) call or a local variable initialized with one.
From the rule's source, thread_run_call.rs.
fun startWorkers(task: Runnable) { Thread { work() }.run()tx0 reports: run() runs the thread's work on the calling thread val worker = Thread(task) worker.run()tx0 reports: run() runs the thread's work worker.start() task.run()} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:thread-run-instead-of-start" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:thread-run-instead-of-start] reason="..."tx0 explain tx0/kotlin:thread-run-instead-of-start shows the same in the terminal. Found a false positive? Report it.