public void run() { long end = System.currentTimeMillis(); long result = (allCount * 1000) / (end - start); String logStr = "consume " + (end - start) + "ms, perfermance: " + result + "/s"; log.info(logStr); System.out.println(logStr); threadExecutor.shutdown(); }
public void run() { for (int j = 0; j < runnableCount; j++) { final int x = j; int i = 0; while (i++ < submitCount) { for (int n = 0; n < recordCountPerSubmit; n++) { // 往队列里加对象,相当于生产者 myRunnables[x].getMsgQueue().add(x + "-" + i + "-" + n); } threadExecutor.execute(myRunnables[x]); // 提交到线程池 try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } } } }