Package java.util.concurrent

Examples of java.util.concurrent.ThreadFactory.newThread()


            public void run()
            {
                // Do nothing.
            }
        };
        Thread thread1 = threadFactory.newThread(doNothing);
        assert thread1.getName().startsWith("Test") : "Wrong thread name: " + thread1.getName();
        assert thread1.getPriority() == Thread.MIN_PRIORITY : "Wrong priority: " + thread1.getPriority();
        assert thread1.isDaemon() : "Thread should be a daemon.";

        // Second thread should have a different name.
View Full Code Here


        assert thread1.getName().startsWith("Test") : "Wrong thread name: " + thread1.getName();
        assert thread1.getPriority() == Thread.MIN_PRIORITY : "Wrong priority: " + thread1.getPriority();
        assert thread1.isDaemon() : "Thread should be a daemon.";

        // Second thread should have a different name.
        Thread thread2 = threadFactory.newThread(doNothing);
        assert thread2.getName().startsWith("Test") : "Wrong thread name: " + thread2.getName();
        assert !thread1.getName().equals(thread2.getName()) : "Thread names should be different.";
    }

View Full Code Here

            public void run()
            {
                // Do nothing.
            }
        };
        Thread thread = threadFactory.newThread(doNothing);
        assert thread.getName().startsWith("Test") : "Wrong thread name: " + thread.getName();
        assert thread.getPriority() == Thread.MAX_PRIORITY : "Wrong priority: " + thread.getPriority();
        assert !thread.isDaemon() : "Thread should not be a daemon.";
    }
View Full Code Here

            public void run()
            {
                throw new IllegalStateException("This is a test.");
            }
        };
        Thread thread = threadFactory.newThread(doNothing);
        thread.start();
        thread.join();

        String output = byteStream.toString();
        assert output.startsWith("java.lang.IllegalStateException") : "Exception handler failed to log exception.";
View Full Code Here

            public void run()
            {
                throw new IllegalStateException("This is a test.");
            }
        };
        Thread thread = threadFactory.newThread(doNothing);
        thread.start();
        thread.join();
        assert exceptionHandler.getExceptionCount() == 1 : "Exception not thrown.";
    }
View Full Code Here

    }

    @Override
    public Thread newThread(String name, Runnable runnable) {
        ThreadFactory factory = createThreadFactory(name, true);
        return factory.newThread(runnable);
    }

    @Override
    public ExecutorService newDefaultThreadPool(Object source, String name) {
        return newThreadPool(source, name, getDefaultThreadPoolProfile());
View Full Code Here

      final UncaughtExceptionHandler handler) {
    final ThreadFactory namedFactory = getNamedThreadFactory(prefix);
    return new ThreadFactory() {
      @Override
      public Thread newThread(Runnable r) {
        Thread t = namedFactory.newThread(r);
        if (handler != null) {
          t.setUncaughtExceptionHandler(handler);
        }
        if (!t.isDaemon()) {
          t.setDaemon(true);
View Full Code Here

  synchronized void start(UncaughtExceptionHandler eh) {
    ThreadFactory flusherThreadFactory = Threads.newDaemonThreadFactory(
        server.getServerName().toShortString() + "-MemStoreFlusher", eh);
    for (int i = 0; i < flushHandlers.length; i++) {
      flushHandlers[i] = new FlushHandler("MemStoreFlusher." + i);
      flusherThreadFactory.newThread(flushHandlers[i]);
      flushHandlers[i].start();
    }
  }

  boolean isAlive() {
View Full Code Here

  private void setThreadFactory(WorkQueue.Executor executor) {
    final ThreadFactory parent = executor.getThreadFactory();
    executor.setThreadFactory(new ThreadFactory() {
      @Override
      public Thread newThread(final Runnable task) {
        final Thread t = parent.newThread(task);
        t.setPriority(Thread.MIN_PRIORITY);
        return t;
      }
    });
  }
View Full Code Here

            }

        };

        for (int ii = 0; ii < threadPoolSize; ii++) {
            tf.newThread(new Runnable() {
                @Override
                public void run() {
                    //final ArrayDeque<VoltPortFutureTask> nextTasks = new ArrayDeque<VoltPortFutureTask>(3);0
                    while (true) {
                        try {
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.