Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService


        final IRepositoryReader repo = pPathElement.getReader();

        if (!executors.containsKey(repo))
            executors.put(repo, Executors.newSingleThreadExecutor());

        final ExecutorService service = executors.get(repo);
        LOG.trace("Submitting fetch task for repo executor " + repo.getRootURI());
        return service.submit(new ChildFetcher(pPathElement));
    }
View Full Code Here


            String title = null;
            wikiparserrecord poison = newRecord();
            int threads = Math.max(2, Runtime.getRuntime().availableProcessors() - 1);
            BlockingQueue<wikiparserrecord> in = new ArrayBlockingQueue<wikiparserrecord>(threads * 10);
            BlockingQueue<wikiparserrecord> out = new ArrayBlockingQueue<wikiparserrecord>(threads * 10);
            ExecutorService service = Executors.newFixedThreadPool(threads + 1);
            convertConsumer[] consumers = new convertConsumer[threads];
            Future<?>[] consumerResults = new Future[threads];
            for (int i = 0; i < threads; i++) {
                consumers[i] = new convertConsumer(in, out, poison);
                consumerResults[i] = service.submit(consumers[i]);
            }
            convertWriter   writer = new convertWriter(out, poison, targetdir, targetstub);
            Future<Integer> writerResult = service.submit(writer);
           
            wikiparserrecord record;
            int q;
            while ((t = r.readLine()) != null) {
                if ((p = t.indexOf("<base>")) >= 0 && (q = t.indexOf("</base>", p)) > 0) {
View Full Code Here

       
        // init reader, producer and consumer
        PositionAwareReader in = new PositionAwareReader(dumpFile);
        indexProducer producer = new indexProducer(100, idxFromWikimediaXML(dumpFile));
        wikiConsumer consumer = new wikiConsumer(100, producer);
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> producerResult = service.submit(consumer);
        Future<Integer> consumerResult = service.submit(producer);
        service.shutdown();
       
        // read the wiki dump
        long start, stop;
        while (in.seek(pagestartb)) {
            start = in.pos() - 6;
View Full Code Here

     * @param bufferSize
     * @return
     */
    public final static initDataConsumer asynchronusInitializer(final String name, final int keylength, final ByteOrder objectOrder, final int idxbytes, final int expectedspace) {
        final initDataConsumer initializer = new initDataConsumer(new HandleMap(keylength, objectOrder, idxbytes, expectedspace, name));
        final ExecutorService service = Executors.newSingleThreadExecutor();
        initializer.setResult(service.submit(initializer));
        service.shutdown();
        return initializer;
    }
View Full Code Here

        }

        // create a concurrent thread that consumes data as it is read
        // and computes the md5 while doing IO
        final md5FilechunkConsumer md5consumer = new md5FilechunkConsumer(1024 * 64, 8);
        final ExecutorService service = Executors.newSingleThreadExecutor();
        final Future<MessageDigest> md5result = service.submit(md5consumer);
        service.shutdown();

        filechunk c;
        try {
            while (true) {
                c = md5consumer.nextFree();
View Full Code Here

     * @param timeout
     * @return
     * @throws ExecutionException
     */
    public E call(final long timeout) throws ExecutionException {
        final ExecutorService service = Executors.newSingleThreadExecutor();
        try {
            final Future<E> taskFuture = service.submit(this.call);
            final Runnable t = new Runnable() {
                public void run() { taskFuture.cancel(true); }
            };
            service.execute(t);
            service.shutdown();
            try {
                return taskFuture.get(timeout, TimeUnit.MILLISECONDS);
            } catch (final CancellationException e) {
                // callable was interrupted
                throw new ExecutionException(e);
View Full Code Here

      Connection connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      pool.release(connection);
      connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      ExecutorService service = Executors.newSingleThreadExecutor();
      service.invokeAny(Collections.singleton(new Callable<Connection>() {
        @Override
        public Connection call() throws Exception {
          return pool.acquire(host);
        }
      }), 2, TimeUnit.SECONDS);
View Full Code Here

      Connection connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      pool.release(connection);
      connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      ExecutorService service = Executors.newSingleThreadExecutor();
      service.invokeAny(Collections.singleton(new Callable<Connection>() {
        @Override
        public Connection call() throws Exception {
          return pool.acquire(host);
        }
      }), 2, TimeUnit.SECONDS);
View Full Code Here

    static MBeanServerConnection server;   

    public static void main(String[] args) throws Exception
    {
 
    final ExecutorService executor = Executors.newCachedThreadPool();

    // Configure the client.
    ClientBootstrap bootstrap = new ClientBootstrap(
            new NioClientSocketChannelFactory(
                executor,
                executor));

    bootstrap.setOption(
            "remoteAddress", new InetSocketAddress("localhost", 8080));

    bootstrap.setOption("reuseAddress", true);

   
    final HessianProxyFactory factory = new HessianProxyFactory(executor, "localhost:8080");
    bootstrap.setPipelineFactory(
            new RPCClientSessionPipelineFactory(new RPCClientMixinPipelineFactory(executor, factory), bootstrap));
   

    factory.setDisconnectedListener(new Runnable()
    {
      public void run()
      {
      //stop = true;
      }
    });

factory.setNewSessionListener(new Runnable()
{
  public void run()
  {
    stop = false;
    executor.execute(new Runnable()
    {
      public void run()
      {
          System.out.println("started work thread");
          Map options = new HashMap();
View Full Code Here

    static HubServiceServer hubServiceServer;


  public static void main(String[] args) throws Exception
  {
      ExecutorService executor = Executors.newCachedThreadPool();
     
      loadData();
     
      new Timer("hosts updater", true).schedule(new TimerTask()
      {
View Full Code Here

TOP

Related Classes of java.util.concurrent.ExecutorService

Copyright © 2018 www.massapicom. 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.