Package java.util.concurrent

Examples of java.util.concurrent.ScheduledExecutorService.shutdown()


                }
                Thread.sleep(30);
                mk.merge(branchId, null);
            }
        } finally {
            gcExecutor.shutdown();
        }
    }

    @Test
    public void putTokenImpl() throws InterruptedException, ExecutionException {
View Full Code Here


        // wake up threads waiting on this instance's monitor (e.g. workspace janitor)
        notifyAll();

        // Shut down the executor service
        ScheduledExecutorService executor = context.getExecutor();
        executor.shutdown();
        try {
            // Wait for all remaining background threads to terminate
            if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
                log.warn("Attempting to forcibly shutdown runaway threads");
                executor.shutdownNow();
View Full Code Here

        e.printStackTrace();
      }
    }
   
    // Finish the executor
    executor.shutdown();
    System.out.printf("Main: No more tasks at: %s\n",new Date());
    // Verify that the periodic tasks no is in execution after the executor shutdown()
    try {
      TimeUnit.SECONDS.sleep(5);
    } catch (InterruptedException e) {
View Full Code Here

      Task task=new Task("Task "+i);
      executor.schedule(task,i+1 , TimeUnit.SECONDS);
    }
   
    // Finish the executor
    executor.shutdown();
   
    // Waits for the finalization of the executor
    try {
      executor.awaitTermination(1, TimeUnit.DAYS);
    } catch (InterruptedException e) {
View Full Code Here

                mk.commit("/a/b/c/d/e", "+\"f\" : {}", mk.getHeadRevision(), null);
                Thread.sleep(30);
                mk.commit("/a/b/c/d", "-\"e\"", mk.getHeadRevision(), null);
            }
        } finally {
            gcExecutor.shutdown();
        }
    }

    /**
     * Verify garbage collection can run concurrently with branch & merge.
View Full Code Here

                }
                Thread.sleep(30);
                mk.merge(branchId, null);
            }
        } finally {
            gcExecutor.shutdown();
        }
    }

    /**
     * Parses the provided string into a {@code JSONArray}.
View Full Code Here

      }
    } finally {
      if (result != null) result.cancel(false);
      monkey.stop("Stopping the test");
      monkey.waitForStop();
      executorService.shutdown();
    }
  }

  @Override
  protected String[] getArgsForLoadTestTool(String mode, String modeSpecificArg, long startKey,
View Full Code Here

            public void run() {
                ran += 1;
            }
        });
        st1.reschedule(0, null);
        ses.shutdown();
        ses.awaitTermination(5, TimeUnit.SECONDS);

        assertEquals("Check that task ran", 1, ran);
    }
View Full Code Here

        });
        long start = System.nanoTime();
        st1.reschedule(10, TimeUnit.MILLISECONDS);
        assertFalse("Check that task hasn't run yet", ran > 0);

        ses.shutdown();
        ses.awaitTermination(5, TimeUnit.SECONDS);

        assertEquals("Check that task ran", 1, ran);
        assertTrue("Check that time passed appropriately",
                   (time - start) >= TimeUnit.NANOSECONDS.convert(10, TimeUnit.MILLISECONDS));
View Full Code Here

        assertFalse("Check that task hasn't run yet", ran > 0);
        st1.reschedule(20, TimeUnit.MILLISECONDS);
        Thread.sleep(5);
        assertFalse("Check that task hasn't run yet", ran > 0);

        ses.shutdown();
        ses.awaitTermination(5, TimeUnit.SECONDS);

        assertEquals("Check that task ran only once", 1, ran);
        assertTrue("Check that time passed appropriately: " + (time - start),
                (time - start) >= TimeUnit.NANOSECONDS.convert(55, TimeUnit.MILLISECONDS));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.