Use the Servlet Thread to Process Events

By default, ZK processes an event in an independent thread called the event processing thread. Thus, the developer can suspend and resume the execution at any time, without blocking the servlet thread from sending back the responses to the browser.

However, it consumes more memory, especially if there are a lot suspended threads, and it may cause some challenge to integrate with other systems that storing information at the Servlet thread's local storage.

ZK provides an option to let you disable the use of the event processing threads. In other words, you can force ZK to process events all in the Servlet threads like other conventional frameworks. Of course, you cannot suspend the execution if the Servlet thread is used.

To disable the use of the event processing threads, you have to specify the following content in WEB-INF/zk.xml.

<system-config>
    <disable-event-thread/>    
</system-config>

Here is the advantages and limitations about using the Servlet thread to process events. In the following sections we will talk more about the limitations and workarounds when using the Servlet thread.

Using Servlet Thread

Using Event Processing Thread

Integration

Less integration issues.

Many containers assume the HTTP request is handled in the servlet thread.

You may have to implement EventThreadInit and/or EventThreadCleanup to solve the integration issue.

ZK and the community keep providing versatile implementations to solve the integration issue.

SuspendResume

No way to suspend the execution of the event listener.

For example, you cannot create a modal window.

No limitation at all.