type=page
status=published
title=Administering Thread Pools
next=webapps.html
prev=jvm.html
~~~~~~

= Administering Thread Pools

[[GSADG00008]][[abluc]]


[[administering-thread-pools]]
== 5 Administering Thread Pools

This chapter provides procedures for administering thread pools in the
GlassFish Server Open Source Edition 7 environment by using the
`asadmin` command-line utility.

The following topics are addressed here:

* link:#ggjyv[About Thread Pools]
* link:#ablud[Configuring Thread Pools]

Instructions for accomplishing these tasks by using the Administration
Console are contained in the Administration Console online help.

[[ggjyv]][[GSADG00546]][[about-thread-pools]]

=== About Thread Pools

The Virtual Machine for the Java platform (Java Virtual Machine) or JVM
machine) can support many threads of execution simultaneously. To help
performance, GlassFish Server maintains one or more thread pools. It is
possible to assign specific thread pools to connector modules, to
network listeners, or to the Object Request Broker (ORB).

One thread pool can serve multiple connector modules and enterprise
beans. Request threads handle user requests for application components.
When GlassFish Server receives a request, it assigns the request to a
free thread from the thread pool. The thread executes the client's
requests and returns results. For example, if the request needs to use a
system resource that is currently busy, the thread waits until that
resource is free before allowing the request to use that resource.

[[ablud]][[GSADG00547]][[configuring-thread-pools]]

=== Configuring Thread Pools

You can specify the minimum and maximum number of threads that are
reserved for requests from applications. The thread pool is dynamically
adjusted between these two values.

The following topics are addressed here:

* link:#ggkwj[To Create a Thread Pool]
* link:#giuff[To List Thread Pools]
* link:#ggkyc[To Update a Thread Pool]
* link:#ggkwy[To Delete a Thread Pool]

[[ggkwj]][[GSADG00366]][[to-create-a-thread-pool]]

==== To Create a Thread Pool

Use the `create-threadpool` subcommand in remote mode to create a thread
pool.

The minimum thread pool size that is specified signals the server to
allocate at least that many threads in reserve for application requests.
That number is increased up to the maximum thread pool size that is
specified. Increasing the number of threads available to a process
allows the process to respond to more application requests
simultaneously.

If one resource adapter or application occupies all the GlassFish Server
threads, thread starvation might occur. You can avoid this by dividing
the GlassFish Server threads into different thread pools.

1. Ensure that the server is running. Remote subcommands require a running server.
2. Create a new thread pool by using the
link:../reference-manual/create-threadpool.html#GSRFM00060[`create-threadpool`] subcommand.
+
Information about options for the subcommand is included in this help
page.
3. To apply your changes, restart GlassFish Server.
+
See link:domains.html#ginqj[To Restart a Domain].
+

[NOTE]
====
Restart is not necessary for thread pools used by the web container.
====


[[GSADG00162]][[giuez]]
Example 5-1 Creating a Thread Pool

This example creates `threadpool-l`.

[source]
----
asadmin> create-threadpool --maxthreadpoolsize 100
--minthreadpoolsize 20 --idletimeout 2 --workqueues 100 threadpool-1
Command create-threadpool executed successfully
----

[[GSADG853]]

See Also

You can also view the full syntax and options of the subcommand by
typing `asadmin help create-threadpool` at the command line.

[[giuff]][[GSADG00367]][[to-list-thread-pools]]

==== To List Thread Pools

Use the `list-threadpools` subcommand in remote mode to list the
existing thread pools.

1. Ensure that the server is running. Remote subcommands require a running server.
2. List the existing thread pools by using the
link:../reference-manual/list-threadpools.html#GSRFM00204[`list-threadpools`] subcommand.

[[GSADG00163]][[giugs]]
Example 5-2 Listing Thread Pools

This example lists the existing thread pools.

[source]
----
asadmin> list-threadpools
threadpool-1
Command list-threadpools executed successfully
----

[[GSADG854]]

See Also

You can also view the full syntax and options of the subcommand by
typing `asadmin help list-threadpools` at the command line.

[[ggkyc]][[GSADG00368]][[to-update-a-thread-pool]]

==== To Update a Thread Pool

Use the `set` subcommand to update the values for a specified thread
pool.

1. List the existing thread pools by using the
link:../reference-manual/list-threadpools.html#GSRFM00204[`list-threadpools`] subcommand.
2. Modify the values for a thread pool by using the
link:../reference-manual/set.html#GSRFM00226[`set`] subcommand.
+
The thread pool is identified by its dotted name.
3. To apply your changes, restart GlassFish Server.
+
See link:domains.html#ginqj[To Restart a Domain].
+

[NOTE]
====
Restart is not necessary for thread pools used by the web container.
====


[[GSADG00164]][[giuhc]]
Example 5-3 Updating a Thread Pool

This example sets the `max-thread-pool-size` from its previous value to
8. [source]
----
asadmin> set server.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=8
Command set executed successfully
----

[[GSADG855]]

See Also

You can also view the full syntax and options of the subcommand by
typing `asadmin help set` at the command line.

[[ggkwy]][[GSADG00369]][[to-delete-a-thread-pool]]

==== To Delete a Thread Pool

Use the `delete-threadpool` subcommand in remote mode to delete an
existing thread pool. Deleting a thread pool will fail if that pool is
referenced by a network listener.

1. Ensure that the server is running. Remote subcommands require a running server.
2. List the existing thread pools by using the
link:../reference-manual/list-threadpools.html#GSRFM00204[`list-threadpools`] subcommand.
3. Delete the specified thread pool by using the
link:../reference-manual/delete-threadpool.html#GSRFM00111[`delete-threadpool`] subcommand.
4. To apply your changes, restart GlassFish Server.
+
See link:domains.html#ginqj[To Restart a Domain].
+

[NOTE]
====
Restart is not necessary for thread pools used by the web container.
====


[[GSADG00165]][[giugt]]
Example 5-4 Deleting a Thread Pool

This example deletes `threadpool-1`.

[source]
----
asadmin> delete-threadpool threadpool-1
Command delete-threadpool executed successfully
----

[[GSADG856]]

See Also

You can also view the full syntax and options of the subcommand by
typing `asadmin help delete-threadpool` at the command line.


