Examples of newThread()


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

        ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
        Runnable r = EasyMock.createMock(Runnable.class);
        final int orgPriority = Thread.NORM_PRIORITY + 1;
        Thread t = new Thread();
        t.setPriority(orgPriority);
        EasyMock.expect(wrapped.newThread(r)).andReturn(t);
        EasyMock.replay(wrapped, r);
        BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
        assertSame("Wrong thread", t, factory.newThread(r));
        assertEquals("Wrong priority", orgPriority, t.getPriority());
        EasyMock.verify(wrapped, r);
View Full Code Here

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

        ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
        Runnable r = EasyMock.createMock(Runnable.class);
        Thread.UncaughtExceptionHandler handler = EasyMock
                .createMock(Thread.UncaughtExceptionHandler.class);
        Thread t = new Thread();
        EasyMock.expect(wrapped.newThread(r)).andReturn(t);
        EasyMock.replay(wrapped, r, handler);
        BasicThreadFactory factory = builder.wrappedFactory(wrapped)
                .uncaughtExceptionHandler(handler).build();
        assertSame("Wrong thread", t, factory.newThread(r));
        assertEquals("Wrong exception handler", handler, t
View Full Code Here

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

        Runnable r = EasyMock.createMock(Runnable.class);
        Thread.UncaughtExceptionHandler handler = EasyMock
                .createMock(Thread.UncaughtExceptionHandler.class);
        Thread t = new Thread();
        t.setUncaughtExceptionHandler(handler);
        EasyMock.expect(wrapped.newThread(r)).andReturn(t);
        EasyMock.replay(wrapped, r, handler);
        BasicThreadFactory factory = builder.wrappedFactory(wrapped).build();
        assertSame("Wrong thread", t, factory.newThread(r));
        assertEquals("Wrong exception handler", handler, t
                .getUncaughtExceptionHandler());
View Full Code Here

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

        ? builder.backingThreadFactory
        : Executors.defaultThreadFactory();
    final AtomicLong count = (nameFormat != null) ? new AtomicLong(0) : null;
    return new ThreadFactory() {
      @Override public Thread newThread(Runnable runnable) {
        Thread thread = backingThreadFactory.newThread(runnable);
        if (nameFormat != null) {
          thread.setName(String.format(nameFormat, count.getAndIncrement()));
        }
        if (daemon != null) {
          thread.setDaemon(daemon);
View Full Code Here

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

    synchronized (config) {
      config.validate();
      ThreadFactory factory = config.getThreadFactory();
      allocator = new BAllocThread<T>(live, dead, config, poisonPill);
      allocatorThread = factory.newThread(allocator);
      deallocRule = config.getExpiration();
      metricsRecorder = config.getMetricsRecorder();
    }
    allocatorThread.start();
  }
View Full Code Here

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

      config.validate();
      ThreadFactory factory = config.getThreadFactory();
      metricsRecorder = config.getMetricsRecorder();
      allocator = new QAllocThread<T>(
          live, dead, config, poisonPill, metricsRecorder);
      allocatorThread = factory.newThread(allocator);
      deallocRule = config.getExpiration();
    }
    allocatorThread.start();
  }
View Full Code Here

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

  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

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

      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);
        } else {
          t.setUncaughtExceptionHandler(LOGGING_EXCEPTION_HANDLER);
        }
View Full Code Here

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

    public void testNewThreadNamingPattern() {
        ThreadFactory wrapped = EasyMock.createMock(ThreadFactory.class);
        Runnable r = EasyMock.createMock(Runnable.class);
        final int count = 12;
        for (int i = 0; i < count; i++) {
            EasyMock.expect(wrapped.newThread(r)).andReturn(new Thread());
        }
        EasyMock.replay(wrapped, r);
        BasicThreadFactory factory = builder.wrappedFactory(wrapped)
                .namingPattern(PATTERN).build();
        for (int i = 0; i < count; i++) {
View Full Code Here

Examples of javax.enterprise.concurrent.ManagedThreadFactory.newThread()

                InitialContext ctx = new InitialContext();
               
                ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/DefaultManagedThreadFactory");
//                ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("concurrent/myExecutor");
                out.println("Getting ManageableThread<br>");
                Thread thread = factory.newThread(new MyTask(2));
                out.println("Starting thread<br>");
                thread.start();
                out.println("Thread started<br><br>");
            } catch (NamingException ex) {
                Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex);
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.