Multithreading in websphere

I have a multithreading application, so I implemented ExecutorService

with a pool size of 5 threads

public class SimpleThreadPool {    
    public static void main(String[] args) {
        ExecutorService executor = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 10; i++) {
          Runnable worker = new WorkerThread("" + i);
          executor.execute(worker);
        }
        executor.shutdown();
        while (!executor.isTerminated()) {
        }
        System.out.println("Finished all threads");
    }
}

      

The application will be deployed to a Websphere web server with settings that have a thread pool configuration: application servers -> thread pools> default, the maximum size is set to 60.

My question is what kind of pool size configuration is done, does the configuration in Websphere make the same as in the code (5 threads)?

+3


source to share


2 answers


These two things have nothing to do with each other.

The server parameter refers to the streams used by the server. See Documentation:

Use this page to configure the thread group used by the application server. Requests are sent to the server via any of the HTTP transports. A thread pool allows server components to reuse threads to eliminate the need to create new threads at runtime. Creating new threads takes time and resources.



Your application now creates its own thread pool of its own

Which has nothing for this system pool.

Of course, it's possible that your application can submit "tasks" to this pool of system threads; using it this way.

+2


source


No, these will be different thread pools.

For those with 60 threads, it needs to be explained via the jndi service by name. The Websphere thread pool is slightly different. For example, it supports JTA (distributed) transactions. You can only use JTA transactions on those special thread pools.



Local will have 5 threads and will not be affected by Websphere in any way. You can check the number of threads by submitting many tasks and then print the thread stacks via jstack or kill -3 command.

+2


source







All Articles