Using threadpoolExecutor

Hi I want to use the threadpool provided in java. i.e Threadpoolexecutor.
The requirement is:
1. I need to have a corepool size(1)
2. I need to have Maxpoolsize(40)
3. I need to have a Queue without predefined capacity. I can use a LinkedBlockingQueue for this.
But the problem is, if i construct a threadpool,
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1,40,600, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
No new threads are created until the queue is full. I.e the no more than corePoolSize threads will ever be created. (And the value of the maximumPoolSize therefore doesn't have any effect.). But what i need to have is everytime a task is submitted, it should create a thread until it reaches MaxpoolSize() and then it should start Queing requests.
Is there a way to do So.....

JoachimSauer ,
What you have made is both corepoolsize and maxpoolsizeequal, in which case its a fixedthreadpool.
I suggest you to go through javadoc for correct explanation on how threadpoolexecutor works.
Below attached is the code which exactly explains the problem.
As you can see, the first task is created until it is completed and all other tasks wait on it.
When you run the code, you will see that even though 50 tasks are pending, no new threads are created,
since the first thread is blocked on a sleep, and the queue is not full. hence eventhough the maxpoolsize is 40,
only one thread is created.
package testThreadPool;
public class sampleRunnable extends Thread{
     public void run()
          try {
               System.out.println("Inside : " + this.getName());
               Thread.sleep(Integer.MAX_VALUE);
               System.out.println("Finished : " + this.getName());
          } catch (InterruptedException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
package testThreadPool;
import java.util.Vector;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ThreadPoolExecutor;
* @author hpke
public class testSampleRunnable {
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1,40,600, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
          for ( int i=0;i <50; i++){
               try {
                    Thread.sleep(1000);
               } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               threadPool.execute(new sampleRunnable());
               Vector<String> threadPoolInfo = new Vector();
             threadPoolInfo.add("++ Thread Pool Info++");
             threadPoolInfo.add("getPoolSize() : " + threadPool.getPoolSize());
             threadPoolInfo.add("getActiveCount() : " + threadPool.getActiveCount());
             threadPoolInfo.add("getCompletedTaskCount() : " + threadPool.getCompletedTaskCount());
             threadPoolInfo.add("getCorePoolSize() : " + threadPool.getCorePoolSize());
             threadPoolInfo.add("getMaximumPoolSize() : " + threadPool.getMaximumPoolSize());
             threadPoolInfo.add("getLargestPoolSize() : " + threadPool.getLargestPoolSize());
             threadPoolInfo.add("getTaskCount() : " + threadPool.getTaskCount());
             threadPoolInfo.add("getKeepAliveTime() : " + threadPool.getKeepAliveTime(TimeUnit.SECONDS));
            String aa = new String();
            for ( int j=0;j< threadPoolInfo.size() ; j++)
                 aa += threadPoolInfo.elementAt(j) + "\n";
            System.out.println(aa);
}

Similar Messages

  • Problem when using ThreadPoolExecutor under Linux

    I am writing a multithreading web page fetcher under windows with jdk1.5.0-09. I have a task dispatcher like this:
    public void run() {
         while (true) {
              try {
               if(_fetcherPool.getActiveCount()<_config.numThreads){
                   _fetcherPool.execute(new RobotstxtFetcher(_crawler, getURLQueue().take()));
                } else {
                   Thread.sleep(someDelay);
              } catch (InterruptedException e) {
                   log.error("Dispatcher.run", e);
    }Everything works fine as expected, 500 threads are generated, and new tasks will be submitted to the pool. I got performance of finishing 20 tasks per second.
    But when I moved this program to Redhat Enterprise Linux with jdk1.5.0_09, the behavior changed completely. 500 threads are still generated. But they are not processing anything for about 60 seconds, but then suddenly finished about 300 tasks in 1-2 seconds. Then the program will wait for another 60 seconds and then finish 300 tasks in 1-2 seconds again.
    So I tried to test it with multithread without using threadpoolexecutor. I generated 500 threads, and each thread get tasks from the queue directly without thread pooling. It works fine just as under windows.
    Can anyone tell me why?
    BTW, I suspect the creation of the thread pool may be an issue. Here's my code:
    ThreadPoolExecutor _fetcherPool = new ThreadPoolExecutor(
         500, 500+20, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>() );Please help. Thanks.
    Message was edited by:
    okss

    I can't see the picture. Maybe host somewhere else and post a link?

  • How to use ThreadPoolExecutor / ArrayBlockingQueue with event objects

    I am having some trouble figuring out how to use the new java.util.concurrent library for a simple thread pool that has custom threads pulling off event objects from a queue.
    I started with this kind of code below, which I know is not right but am having trouble seeing the correct approach. Any help is appreciated. Thank You!
    -Paul
    public class testThreadPool {
    public static void main( String [] args ) {
    //work queue actaully only takes runnables,
    //but I need to add my event objects to this queue ??
    ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(20);
    ThreadPoolExecutor pool = new ThreadPoolExecutor(10,//pool size
    20,//max pool size
    1,
    TimeUnit.SECONDS,
    workQueue);//the work queue
    //this will ensure that the pool executor creates worker
    //threads of type MyThreadWorker
    pool.setThreadFactory(new MyThreadFactory());
    pool.prestartAllCoreThreads();
    //throw some events on the queue and let the pool workers
    //start to execute with the given event object
    workQueue.add(MyEvent);
    workQueue.add(AnotherEvent);
    class MyThreadFactory implements ThreadFactory {
    public Thread newThread(Runnable runnable) {
    return new (Thread)MyThreadWorker();
    class MyThreadWorker implements Runnable {
    private boolean m_run = true;
    public void run(){
    Object obj;
    while (m_run) {
    obj = null;
    //get the event object from the blocking queue
    try {
    obj = workQueue.take();
    } catch (InterruptedException e) {
    if ( obj == null ) continue;
    if ( obj == null ) continue;
    if (obj instanceof MyEvent) {
    //do this
    } else if (obj instanceof AnotherEvent) {
    //do this
    public void stopRunning(){
    m_run = false;
    this.interrupt();
    }

    What database and connection type are you using? Are you connecting the report directly to the database, or trying to assign the datasource to object data?
    It sounds like you might be trying to use a linked list, collection or other C# construct to pass your data in. This currently isn't supported by the Crystal Reports SDK. You can use a DataSet or a DataTable, and possibly also an IDataReader depending on which version of Crystal Reports you're referencing in your project. Of course you can also connect directly to the database, even if the database isn't on the same machine as the application.
    The way to show master records with detail information is through the use of subreports and linked subreport parameters. Linked subreports take their parameter value from a record in the main report, so that only the data appropriate to that master record is displayed. The guys over in the [report design|SAP Crystal Reports; forum can help you out with this if you have questions on the specifics.

  • Using ThreadPoolExecutor, wish to obtain thread for known runnable object

    My problem is this:
    I use a ThreadPoolExecutor with default ThreadFactory to create a pair of threads; one operates a live particle simulation, the other mouse interactions with the particles.
    I would like to be able to stop one particle simulation (which is a class extending Runnable) and replace it with another. The problem is that I call myRunnableSimulator.stop(), but then I am unable to join() its thread before creating the new particle simulator, because the ThreadPoolExecutor uses a ThreadFactory. And since I have 2 threads running, Thread.currentThread() isn't much use.
    ThreadedPoolExecutor.awaitTermination(long duration, TimeUnit unit) doesn't help me either, since it waits for all tasks to terminate. I could set the timeout to some duration that feels safe for the thread I want to die to do so, but it's a bit of a fudge.
    Any advice would be much appreciated.

    If the tasks you submit to an executor have termination dependencies then you need to explicitly code them into the task based on its state, not the state of the thread executing the task.
    Thread.join() is a lazy way to asking "has my task finished execution". And it tells you nothing about the success or failure of that execution. myTask.isDone() is what you need - whether isDone comes from a Future or from your own task implementation.

  • Has UnixProcess been improved to use ThreadPoolExecutor to reduce threads

    Hi all,
    I am working on an application where hundreds or thousands of Unix process are created from Java application. The Unix process is an application running in the background with a UI interface. It remains running until user exits the application. While the process is running, I notice there is a thread associates to the process in my Java application.
    Thread name: process reaper, id: 265392
    java.lang.UNIXProcess.waitForProcessExit(Native Method)
    java.lang.UNIXProcess.access$900(UNIXProcess.java:20)
    java.lang.UNIXProcess$1$1.run(UNIXProcess.java:132)
    I have found an article where an improvement had been done to OpenJDK where ThreadPoolExecutor is used to reduce total number of threads wit UnixProcess:
    http://answerpot.com/showthread.php?58084-UNIXProcess%20improvements
    How do I find out the if the latest release of 1.6 contains the fix? If not, if there a bug has been filed for such improvement?
    I am using Java 1.6.0_18-b07 on CentOS 5.1.
    Thanks a lot.

    creating hundreds or thousand of processes is a bad idea and very expensive.
    The thread pool is not a process pool. thread != process. However a thread pool could be used to pool the threads you use to read the output of a process, but that will make such a minor difference to the cost of creating a process I wouldn't bother.

  • How to add timeout for threads which are running  using ThreadPoolExecutor

    I am trying change my existing functionality with ThreadPoolExecutor. I was unable to achieve fully.
    Here is my issue.
    I was creating multiple threads for independent DB update operations. And was calling join with time value on the each thread, for any reason if the db update hangs so that thread should die.
    Now am trying use a nice ThreadPoolExecutor so that it can run and queue the threads nicely. But how do I create the timeout values for the threads which are in the ThreadPool. For any reason if the thread hangs then timeout will take care of killing the thread. When we use execute method submit the runnable task its not guaranteed that thread will run immediately. So when the executor will execute the submitted task is not know.
    Probably I might be wrong some where.
    Thanks.

    Future task = threadPoolExecutor.submit(...);
    //this will block until it finishes or times out.
    task.get(REQUEST_TIMEOUT, TimeUnit.MILLISECONDS);

  • Custom ThreadPoolExecutor

    Hello,
    Suppose you need a thread pool with the following behavior:
    maxThreads = Max number of threads can be in the pool.
    If a thread have been idle for more than X seconds, then the thread must die.
    When a task is submitted:
    if (there is an idle thread in the pool) {
        use the idle thread to execute the task.
    } else {
        if (current number of threads < MaxThreads) {
            create a new thread and use it to execute the task.
        } else {
            put the task in a queue.
            the task will be executed when a thread becomes available.
    }How can configure a ThreadPoolExecutor to achieve this?
    If you use this:
    new ThreadPoolExecutor(maxThreads, maxThreads, X, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())All the threads are in the core, so when you submit a task, a new thread will be created even if there are idle threads in the pool.
    Besides, the core threads don't die by timeout.
    If you use this:
    new ThreadPoolExecutor(0, maxThreads, X, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())The executor prefer to queue the tasks even if there are idle threads or more threads can be created.
    Thanx

    JoseLuis wrote:
    Hello,
    Suppose you need a thread pool with the following behavior:
    maxThreads = Max number of threads can be in the pool.
    If a thread have been idle for more than X seconds, then the thread must die.
    When a task is submitted:
    if (there is an idle thread in the pool) {
    use the idle thread to execute the task.
    } else {
    if (current number of threads < MaxThreads) {
    create a new thread and use it to execute the task.
    } else {
    put the task in a queue.
    the task will be executed when a thread becomes available.
    }How can configure a ThreadPoolExecutor to achieve this?
    If you use this:
    new ThreadPoolExecutor(maxThreads, maxThreads, X, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())All the threads are in the core, so when you submit a task, a new thread will be created even if there are idle threads in the pool.
    Besides, the core threads don't die by timeout.Not by default but if you use [ThreadPoolExecutor#allowCoreThreadTimeOut(boolean)|http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html#allowCoreThreadTimeOut(boolean)] they do.
    >
    If you use this:
    new ThreadPoolExecutor(0, maxThreads, X, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())The executor prefer to queue the tasks even if there are idle threads or more threads can be created.If you want to follow this route you should use a bounded BlockingQueue, like an ArrayBlockingQueue, which will force new thread creation when the Queue is full.
    ThreadPoolExecutor executor = new ThreadPoolExecutor(maxThreads/2, maxThreads, X TimeUnit.Seconds, new ArrayBlockingQueue<Runnable>(maxThreads/2));
    executor.allowCoreThreadTimeOut(true);Gets you near where you want, I think.
    >
    Thanx

  • ThreadPoolExecutor  pros / cons and alternatives.

    Folks,
    I was looking at the ThreadPoolExecutor documentation: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html
    Is ThreadPoolExecutor the most efficient dispatching system ?. Are there any other Classes in Java that can be used to accomplish a similar task, i.e executing asynchronous tasks.
    Also please provide me from your experience if there are pros and cons using alternatives to threadpools.
    _ddt

    Thanks for your prompt response!.
    We are currently using ThreadPoolExecutor to execute a bunch of asynchronous tasks, but the performance of our application degraded very SEVERELY :(.
    When run through a NetBeans profiler, we see that most of the time is being spent in context switching.
    The Documentation for ThreadPoolExecutor Reads:
    To be useful across a wide range of contexts, this class provides many adjustable parameters and extensibility hooks. However, programmers are urged to use the more convenient Executors factory methods Executors.newCachedThreadPool() (unbounded thread pool, with automatic thread reclamation), Executors.newFixedThreadPool(int) (fixed size thread pool) and Executors.newSingleThreadExecutor() (single background thread), that preconfigure settings for the most common usage scenarios. Otherwise, use the following guide when manually configuring and tuning this class:
    So is it better to use the Executor classes ?.
    _ddt                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to find Number of working threads using java executor framework

    I'm creating a java thread pool using java 1.5 executor framework.
    private ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize);
    public <T> Future<T> submit(Callable<T> task) {
              return executorService.submit(task);
    }Now I want to get the number of working thread at runtime. Is there any java api available to do this using java 1.5 executor framework?
    Thanks,
    Arpan

    If the ExecutorService you are working on is a ThreadPoolExecutor then you can use ThreadPoolExecutor#getActiveCount() to get the count of threads actually running tasks. There is no such method on the ExecutorService interface though.

  • Blocking ThreadPoolExecutor

    Hi,
    I'd like to use ThreadPoolExecutor to manage a set number of threads that I have for executing tasks, and have clients of the executor block when all threads in the pool are busy.
    So, in the code below, the first three calls to execute() will cause the Runnable to be executed, but the fourth will block until one of the first three calls completes.
    ThreadPoolExecutor executor = new ThreadPoolExecutor( 0, 3, 0, TimeUnit.MILLISECONDS( 3, 3, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>() );
    while ( true ) {
        executor.execute( new Runnable() {
            public void run() {
                 // do something
    }However I can't seem to find any way of doing this - I always just get a RejectedExecutionException (or if I use a different RejectedExecutionHandler.DiscardPolicy the while loop just spins continuously, occasionally successfully executing a job). Any ideas?

    Thanks for the replys.
    I looked at using a custom RejectedExecutionHandler but then realised I could actually do what I needed less verbosely like this:
    public class BlockingThreadPoolExecutor extends ThreadPoolExecutor {
        private final Semaphore semaphore;
        public BlockingThreadPoolExecutor( int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue ) {
            super( corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue );
            semaphore = new Semaphore( maximumPoolSize, true );
        @Override
        public void execute( Runnable command ) {
            try {
                semaphore.acquire();
            } catch ( InterruptedException e ) {}
            super.execute( command );
        @Override
        protected void afterExecute( Runnable command, Throwable t ) {
            semaphore.release();
    }This works - almost. Unfortunately there is a race condition which means an execution will still be rejected with the following :
    1. three tasks are entered & begin execution on threads A,B and C
    2. thread D submites a fourth task and blocks in execute(), waiting to aquire a permit
    3. thread A completes its task and calls afterExecute(), releasing a permit
    4. D aquires a permit and calls super.execute()
    5. D offers its task to the workQueue BEFORE the thread A either dies or calls take() on the workQueue
    Note that implementing the solution using a RejectedExecutionHandler makes no difference - the problem is to do with there being a small amount of work done after the call to afterExecute() which applies in this case also.
    Can't see away round it, which sucks, so I'm probably going to give up using ThreadPoolExecutor unless anyone has any good ideas?

  • Set timeout for completion of each thread

    i have a requirement where i need to start n threads and set timeout for completion of each thread.
    if the thread is not executed successfully(because of timeout ) i have to enter in audit table that it failed because of timeout
    if executed successfully update audit table with success.
    can some one give me solution for this using ThreadPoolExecutor available jdk1.5

    Add a scheduled task to time out the task (when it would time out). Keep the Future and cancel it if the task completes successfully.
    final Future future = executor.schedule(new TimeoutTask(), timeoutMS, TimeUnit.MILLI_SECONDS);
    executor.execute(new Runnable() {
      public void run() {
          try {
             task.run();
          } finally {
             future.cancel(true);
    });

  • Optimization of Thread Pool Executor

    Hi,
    I am using ThreadPoolexecutor by replacing it with legacy Thread.
    I have created executor as below:
    pool = new ThreadPoolExecutor(coreSize, size, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(coreSize), new CustomThreadFactory(name),new CustomRejectionExecutionHandler());
           pool.prestartAllCoreThreads();
    here core size is maxpoolsize/5
    and i have prestarted all the core threads on start up of application roughly around 160 threads.
    in legacy design we were creating and starting around 670 threads.
    But the point is even after using Executor and creating and replacing  legacy design we are not getting much better results.
    For results memory management we are using top command to see memory usage
    and for time we have placed loggers of System.currentTime in millis to check the usage.
    Please tell how to optimize this design
    Thanks & Regards,
    tushar

    The first step is to decide what you want to optimize. I'm guessing you want to minimize the total elapsed time for the job to run, but anyway that's your first step. Determine what you're optimizing. Then measure the performance of the job, with respect to that metric, for various pool sizes, and see what happens.
    However I'm not sure why you expected that rewriting the application to use the ThreadPoolExecutor would improve the runtime performance of the job. I would expect it might simplify the code and make it easier for future programmers to understand, but it's possible that your thread pool implementation performs just as well.

  • RejectedExecutionHandler choices

    ThreadPoolExecutor offers four predefined RejectedExecutionHandler classes. [http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html]
    [ThreadPoolExecutor.DiscardPolicy|http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.DiscardPolicy.html] and [ThreadPoolExecutor.DiscardOldestPolicy|http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.DiscardOldestPolicy.html] policies are suitable perhaps for some toy applications, but in my cases it is never applicable to discard tasks.
    [ThreadPoolExecutor.AbortPolicy |http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.AbortPolicy.html] throws exception, and that allows to implement custom logic when Executor is overloaded. I almost always use [ThreadPoolExecutor.CallerRunsPolicy|http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html] which is a recommended approach to control the "the rate that new tasks are submitted". But what if it takes a long time to execute a task (for example about 1000 ms), then when the execution of a task is pushed to the caller it wont be able to submit any tasks while processing the rejected task, even there could be several threads freed during that time. Ideally the caller should be blocked until a thread is available. I ended up with something like the following:
    public class WaitForThreadPoolExecutor extends ThreadPoolExecutor {
        final Object sync = new Object();
        public WaitForThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
            super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
        public void execute(Runnable command) {
            try {
                super.execute(command);
            } catch (RejectedExecutionException e) {
                boolean submitted = false;
                synchronized (sync) {
                    while (!submitted) {
                        try {
                            super.execute(command);
                            submitted = true;
                        } catch (RejectedExecutionException e1) {
                            try {
                                sync.wait();
                            } catch (InterruptedException e2) {
                                Thread.currentThread().interrupt();
        protected void afterExecute(Runnable r, Throwable t) {
            super.afterExecute(r, t);
            synchronized (sync) {
                sync.notify();
    }And here is test code:
    public class Test {
        static class SlowRunnable implements Runnable {
            public void run() {
                try {
                    TimeUnit.MILLISECONDS.sleep(1000);
                } catch (InterruptedException e) {}
        public void test() {
            BlockingQueue<Runnable> workQueue = new SynchronousQueue<Runnable>();
            ThreadPoolExecutor exec =
                    new WaitForThreadPoolExecutor(1, 10, 1, TimeUnit.MINUTES, workQueue);
                   // new ThreadPoolExecutor(1, 10, 1, TimeUnit.MINUTES, workQueue, new ThreadPoolExecutor.CallerRunsPolicy());
            long t1 = System.currentTimeMillis();
            while (System.currentTimeMillis() - t1 < 1000 * 60) {
                exec.execute(new SlowRunnable());
            exec.shutdown();
            System.out.println("Number of tasks executed: " + exec.getCompletedTaskCount());
        public static void main(String[] argv) {
            new Test().test();
    }The test simply submits Runnable tasks for one minute to the executor, and each task sleeps for 1000 ms.
    With ThreadPoolExecutor + CallerRunsPolicy I get 360 - 380 completed tasks.
    With WaitForThreadPoolExecutor I get 594 - 597 completed tasks.
    Of course the results will be different when tasks do some real work, especially if the work is CPU bound, but if work is mostly IO, then waiting for a thread may be a better approach then pushing the work to a caller.
    What do you generally use in production code?
    Sergey.

    serenkij wrote:
    ThreadPoolExecutor offers four predefined RejectedExecutionHandler classes. [http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html]
    [ThreadPoolExecutor.DiscardPolicy|http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.DiscardPolicy.html] and [ThreadPoolExecutor.DiscardOldestPolicy|http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.DiscardOldestPolicy.html] policies are suitable perhaps for some toy applications,
    I wouldn't agree. There are definitely requirements where these can be used in very real production code. For example soft realtime applications that want a response only as long as it's request is reasonably fresh and a late response is just as bad as no response at all.
    but in my cases it is never applicable to discard tasks.Ok, that's a perfectly valid requirement. I just wanted to say that it's not always the case.
    What do you generally use in production code?What's wrong with using an unbounded BlockingQueue (such as LinkedBlockingQueue) in those cases so that the ThreadPoolExecutor never rejects jobs?
    The only possible problem I see here is if a really, really massive amount of Runnable builds up and you get an OOM.

  • Repeatability of performance results

    Hello experts
    I have a problem with repeatability of performance test results.
    I'm using Japex (is using ThreadPoolExecutor object) to test performance of Calendar.getInstance() method.
    Parameters:
    run time = 10 seconds,
    number of threads = 10.
    The results are:
    first launch = 178643tps
    second launch = 188834tps
    third launch = 189533tps.
    So optimum evasion is 2%.
    Is it possible to get more repeatable results?
    Which mechanism is better fo these purposes?
    Thanks in advance.

    vetalok wrote:
    The main idea is to test it in comcurrency.Probably the first thing you should do is test something simple that does not involve interactions between threads, and see how it behaves concurrently, to establish a baseline of behavior (a control). That way you have something to compare against.

  • Changing ThreadPoolExecutor to prefer thread use to bounded queue

    I would like to extend ThreadPoolExecutor to create new threads up to maximumPoolSize and then put tasks onto a bounded queue. (Kind of a cross between Fixed and Cached thread pools).
    It seems that the only place to do this would be to rewrite the execute method of ThreadPoolExecutor and swap the following commands
    if (workQueue.offer(command))  // Swap this
      return;
    Runnable r = addIfUnderMaximumPoolSize(command);  // with this
    if (r == command)
      return;
    if (r == null)
      reject(command).
    ...However with most methods and vars private in ThreadPoolExecutor, overriding this method is nearly impossible.
    Is there a better way of doing this?
    Thanks,
    Chris

    nope - there is no chance. sadly not! otherwise i would have integrated it into my templates
    btw - you could change all the links into a rollover, but that would mean that ALL links are a rollover.
    another way is to use iwebmore to edit the template files: http://iwebmore.ctrl-j.eu/iWebMore.html
    max karreth

Maybe you are looking for

  • IMac died, how do I get data off Time Machine to new iMac

    My sisters iMac has had HD problems in the past - we replaced hd at Apple in the past.  I am unable to start the computer up again to look into anything. It was apparently sending out a lot of error messages, the main one being the HD was out of spac

  • Text Object Error in Pdf based print forms

    Hello Friends, I am trying to include a text object in Adobe PDF-based print form. In the context, I have created a node for the text. I chose the Text Type as “Include Text”. I am able to choose the required Text Object and Text ID from the respecti

  • X not starting on new installation

    Hello all! today I decided to try arch for the first time. THe installation went well, but now i cannot get x to start. I have read through most of the xorg wiki and cannot find a way to solve my problem. Here is the crash log: http://bpaste.net/show

  • Using ipod shuffle with more than 1 computer

    Some of my music library is on my work machine and some of it is on my home machine. This has never been an issue with my ipod classic. I plug it into either machine and it connects no problem. Not so with my shuffle. After I loaded it up with songs

  • Palm Error Message?

    I finally got iSync to recognize my Palm (Zire 72), but now when I try to sync I get this error message on my Palm "Unable to initiate HotSync operation becase th eport is in use by another application" My Mac Bluetooth reads that the Palm is connect