List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:com.griddynamics.invoker.SearchInvoker.java
@Override public final Integer invoke(String query, String endpoint) throws InvocationException { /* Preconditions.checkNotNull(query); Preconditions.checkNotNull(endpoint); /*from w w w.j av a 2 s . c o m*/ HttpMethod method = new GetMethod(endpoint); method.setPath(getPath(endpoint, query)); try { int returnCode = httpClient.executeMethod(method); return returnCode; } catch (HttpException e) { log.debug("Error during invocation", e); throw new InvocationException("InvocationException : ", e); } catch (IOException e) { log.debug("Error during invocation", e); throw new InvocationException("InvocationException : ", e); } finally { try { method.releaseConnection(); } catch (Throwable e) { log.error("Cannot release connection", e); } }*/ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return 1; }
From source file:test.TestBackAction.java
/** * {@inheritDoc}//ww w . j av a2 s . co m */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { Date start = new Date(); try { for (int i = 1; i <= 10; i++) { Thread.sleep(1000); setProgress(((double) i) / 10); } final HibernateBackendController bc = (HibernateBackendController) getController(context); bc.getTransactionTemplate().execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { EnhancedDetachedCriteria cityCrit = EnhancedDetachedCriteria.forClass(City.class); cityCrit.add(Restrictions.eq(City.ZIP, "69000")); City lyon = bc.findFirstByCriteria(cityCrit, EMergeMode.MERGE_KEEP, City.class); lyon.setName(Long.toString(System.currentTimeMillis())); } }); // if (System.currentTimeMillis() % 2 == 0) { // throw new NullPointerException( // "This is a test for an unhandled exception on thread " + Thread.currentThread().getName()); // } } catch (InterruptedException ex) { ex.printStackTrace(); } Date end = new Date(); Map<String, Object> completionContext = new HashMap<>(); setActionParameter("Asynchronous action that was started at " + start + "has completed at " + end, completionContext); actionHandler.executeLater(completionAction, completionContext); return super.execute(actionHandler, context); }
From source file:com.alibaba.otter.node.etl.load.WeightControllerTest.java
public void run() { try {/* w w w .ja va2s . c o m*/ controller.start(weights); } catch (InterruptedException e1) { e1.printStackTrace(); } for (Long weight : weights) { try { controller.await(weight); System.out.println(id + " : " + weight); Thread.sleep(50); controller.single(weight); } catch (InterruptedException e) { e.printStackTrace(); } } latch.countDown(); }
From source file:net.librec.job.progress.ProgressReporter.java
@Override public void run() { // get current flag value and reset it as well boolean sendProgress = resetProgressFlag(); while (!taskDone.get()) { try {/*from w w w .ja v a 2s . c om*/ synchronized (lock) { if (taskDone.get()) { break; } lock.wait(PROGRESS_INTERVAL); sendProgress = true; } if (sendProgress) { this.progressx(); } } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:dk.ekot.misc.SynchronizedCacheTest.java
@Test public void testHammering() throws InterruptedException { final int THREADS = 20; final List<String> copied = new ArrayList<>(); final SynchronizedCache sc = new SynchronizedCache() { @Override/*from www. j a v a2 s. c om*/ protected void copy(Path fullSourcePath, Path fullCachePath) throws IOException { try { Thread.sleep(25); } catch (InterruptedException e) { e.printStackTrace(); } copied.add(fullCachePath.toString()); } }; for (int t = 0; t < THREADS; t++) { // Test-copies take ~25ms. Every fifth "copy" should this be processed without delay final String dest = t % 5 == 0 ? "fifth" : "same"; new Thread(() -> { try { sc.add(Paths.get("foo"), Paths.get(dest)); } catch (IOException e) { e.printStackTrace(); } }).start(); Thread.sleep(5); } Thread.sleep(1000); // It should take 19*20ms log.debug("Mock file copy order: " + copied); // There are 4 'fifth's and 16 'same'. As the two groups should be processed practically independently, // The 4 'fifth's should be in the first half of the copied list int fifths = 0; for (int i = 0; i < THREADS / 2; i++) { if ("fifth".equals(copied.get(i))) { fifths++; } } assertEquals("There should be " + THREADS / 5 + " \"copies\" of the file 'fifth' among the first " + THREADS / 2 + " files \"copied\"\n" + copied, THREADS / 5, fifths); }
From source file:localworker.LocalWorker.java
@SuppressWarnings("unchecked") @Override//from www .j a va2 s . c o m public void run() { JSONParser parser = new JSONParser(); JSONObject json; String task_id = null; String task; try { while (true) { //waiting up to 100ms for an element to become available. String messageBody = jobQ.poll(100, TimeUnit.MILLISECONDS); if (messageBody != null) { json = (JSONObject) parser.parse(messageBody); task_id = json.get("task_id").toString(); task = json.get("task").toString(); Thread.sleep(Long.parseLong(task)); JSONObject result = new JSONObject(); result.put("task_id", task_id); result.put("result", "0"); respQ.put(result.toString()); //System.out.println(Thread.currentThread().getName()+" sleep done!"); } } } catch (Exception e) { JSONObject result = new JSONObject(); result.put("task_id", task_id); result.put("result", "1"); try { respQ.put(result.toString()); } catch (InterruptedException e1) { e1.printStackTrace(); } } }
From source file:com.athena.peacock.controller.netty.PeacockServer.java
@PostConstruct public void start() throws Exception { new Thread() { @Override//w w w.ja v a2s. c o m public void run() { try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.WARN)).childHandler(initializer); // Bind and start to accept incoming connections. channel = b.bind(port).sync().channel().closeFuture().sync().channel(); } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); }
From source file:org.tocode.poc.service.PocService.java
/** * Execute async.//from w ww . j a va 2s . c o m */ @Async public void executeAsync() { for (int iteration = 0; iteration < 20; iteration++) { try { System.out.println("Service Iteration: " + iteration); Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:com.cloudbees.jenkins.support.timer.DeadlockTest.java
public void sleep() { try {//from w w w. ja v a 2 s.c o m Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:de.uzk.hki.da.cb.ArchiveReplicationAction.java
private void delay() { try {/*from ww w . java 2 s . com*/ Thread.sleep(timeOut); // to prevent unnecessary small intervals when checking } catch (InterruptedException e) { e.printStackTrace(); } }