Developing high-performance java-EE threads using WebSphere Application Server

Source: Internet
Author: User
Tags thread websphere application server

Introduction

The IBM WebSphere application Server software provides the following two mechanisms to support the safe use of threads in Servlet and EJB components by j2ee™ application developers:

Asynchronous Bean

Commonj Timer and Workmanager for application Servers 1.1 specification.

Both programming modes allow you to create pool and daemon threads to run the Java business logic.

In both programming modes, threads can be reused by different applications. When the application logic starts and terminates, this can be done by applying and deleting the Java context information inside and outside the thread. Therefore, a single thread pool can be used by multiple applications. Each time a thread is used, its identity changes.

Each time you reuse a thread, you must make the context of the thread more specific, and for applications that may rarely perform activities on those threads, the overhead will be particularly high. In these cases, a component-scoped thread pool is required and has a fixed Java EE context on each thread. This can be done by using the asynchronous Beans EventSource interface.

This article describes how to use the asynchronous Beans EventSource to construct a thread factory, which includes a downloadable example called a concurrency adapter (Concurrent Adapter) that can be used with a third-party thread pool implementation to create the ability to A fast thread pool that works on a WebSphere application Server.

Global thread pool

WebSphere application Server delivers high-performance and highly scalable thread pooling implementations. Asynchronous Bean and Commonj Workmanager Use this thread pool for all pool threads.

Because the Workmanager instance can be used for global namespaces, they can be shared across multiple applications, so you need Java context switching. To complete this task, Workmanager takes a snapshot of the Java context on the thread when submitting work. The resulting object becomes the Workwithexecutioncontext (WWEC) object (Figure 1).

Figure 1. Workwithexecutioncontext

If you use Workmanager as the global thread pool (Figure 2), each task that is submitted to the thread pool will have an application context that is applied to the thread (or removed from the thread) each time you assign work to the thread:

Submit work to Workmanager thread pool (blue box)

Gets a snapshot of the Java application context and stores it as a WWEC object with the work.

Add WWEC to the pool's input queue.

The worker thread extracts a WWEC from the input queue and runs it.

Gets a snapshot of the current Java-EE application context on the worker thread to recover after the work completes.

Applies the Java EE context stored with WWEC to the thread.

Run the job.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.