2016-06-09 32 views
5

Mã này hoạt động tốt. Khi khởi động lại máy tính, nó cho tôi lỗi:Ngoại lệ khi cố gắng lấy khóa JMH

ERROR: org.openjdk.jmh.runner.RunnerException: 
ERROR: Exception while trying to acquire the JMH lock (C:\WINDOWS\/jmh.lock): 
Access is denied, exiting. Use -Djmh.ignoreLock=true to forcefully continue. 
at org.openjdk.jmh.runner.Runner.run(Runner.java:213) 
at org.openjdk.jmh.Main.main(Main.java:71) 

Lỗi Google-int không giúp được gì. Ai đó có thể cho tôi biết làm thế nào để sửa chữa nó?

@State(Scope.Thread) 
public class test { 
    public ConcurrentHashMap<String,Integer> i = new ConcurrentHashMap<String, Integer>(10000); 
    public ArrayList<String> k = new ArrayList<String>(10000); 
    public int p=0; 

public void setup(){ 
    for(int m=0;m<1000;m++){ 
     int j=ThreadLocalRandom.current().nextInt(0,10000); 
     String jk=Integer.toString(j); 
     k.add(jk); 
     i.put(jk,j); 
    } 
} 

@Benchmark 
@BenchmarkMode(Mode.Throughput) 
@OutputTimeUnit(TimeUnit.MILLISECONDS) 
@Warmup(iterations = 3) 
@Measurement(iterations = 5) 
public void putKey(){ 
    int n=ThreadLocalRandom.current().nextInt(0,10000); 
    String nk=Integer.toString(n); 
    k.add(nk); 
    i.put(nk,n); 
} 

@Benchmark 
@BenchmarkMode(Mode.Throughput) 
@OutputTimeUnit(TimeUnit.MILLISECONDS) 
@Warmup(iterations = 3) 
@Measurement(iterations = 5) 
public int getKey(){ 
    p=ThreadLocalRandom.current().nextInt(0,10000); 
    p=p%k.size(); 
    return i.get(k.get(p)); 
} 
public static void main(String[] args) throws RunnerException{ 
    Options opt = new OptionsBuilder() 
      .include(".*" + test.class.getSimpleName() + ".*") 
      .forks(1) 
      .build(); 
    new Runner(opt).run(); 
} 

}

+1

Bạn có quyền ghi trong c cửa sổ thư mục ổ đĩa của bạn? –

+0

@SauravSircar Bạn đã thử sử dụng '-Djmh.ignoreLock = true' chưa? Bạn cũng có thể xem [bài đăng này] (http://mail.openjdk.java.net/pipermail/jmh-dev/2016-January/002122.html) –

+1

Bạn đã thử xóa thủ công 'C: \ WINDOWS \/jmh.lock'' tập tin? –

Trả lời

Các vấn đề liên quan