Developers of multithreaded applications have to concern themselves with introducing concurrency defects into their code. A QA software maker has developed a solution to help put the kibosh on concurrency coding errors in Java applications before they cause deleterious effects on production code.
Today, Coverity released Coverity Thread Analyzer for Java, a dynamic analysis tool for multithreaded applications. It analyzes code as it is executed to identify and predict deadlocks and race conditions.
Deadlocks occur when two or more threads are waiting for each other to finish, while race conditions are found when the output of a process is governed by the sequence or timing of process events.
“It is hard to reproduce concurrency errors,” said Andy Chou, Coverity's chief scientist. “Deadlocks depend on exact timing, and tracing bad behavior for race conditions is difficult.”
He noted that engineers had to sift through roughly 3 million lines of code before they identified the root cause of the Northeast Blackout of 2003: a race condition that occurred in General Electric Energy's Unix-based XA/21 energy management system. The power outage affected millions of customers in parts of the United States and Canada.
In creating Thread Analyzer, Coverity created separate algorithms to identify each condition. The deadlock algorithm tracks the sequence of locking orders to create a complete locking reference, and race conditions are identified by checking whether or not shared variables are protected by locks, Chou explained.
Thread Analyzer has integration hooks with Coverity’s Prevent static analysis tool to allow combined dynamic and static analysis. Thread Analyzer uses Prevent’s results to speed up its code analysis.