Removing intrinsic of Thread.isInterrupted()

Aleksey Shipilev aleksey.shipilev at oracle.com
Tue Feb 25 00:36:38 PST 2014


On 02/25/2014 12:31 PM, Florian Weimer wrote:
> On 02/25/2014 02:46 AM, Yumin Qi wrote:
>>          isum = 0L;
>>          for (int i = 0; i < NUM; i++) {
>>              start = System.currentTimeMillis();
>>              t.isInterrupted();
>>              finish = System.currentTimeMillis();
>>              isum += (finish - start);
>>          }
> 
> This benchmark loop looks invalid to me.  I think you have to store the
> result of t.isInterrupted(), perhaps to an array of booleans, and time
> the entire thing, not just the call itself.

Indeed. That's how you do it with JMH:
 https://github.com/shipilev/benchmarks-scratch/blob/master/src/main/java/org/sample/ThreadIsInterrupted.java

On my Linux x86_64, JDK 8b129 the difference is minuscule.

-Aleksey


More information about the hotspot-compiler-dev mailing list