# Configuring the Network Server to handle connections

You can configure the Network Server to use a specific number of threads to handle connections. You can change the configuration on the command line or by using the servlet interface.

The minimum number of threads is the number of threads that are started when the Network Server is booted. This value is specified as a property, `derby.drda.minThreads = <min>`. The maximum number of threads is the maximum number of threads that will be used for connections. If more connections are active than there are threads available, the extra connections must wait until the next thread becomes available. Threads can become available after a specified time, which is checked only when a thread has finished processing a communication.

- You can change the maximum number of threads by using the following command:

      java org.apache.derby.drda.NetworkServerControl maxthreads <max> [-h <hostname>]
      [-p <portnumber>]

  You can also use the `derby.drda.maxThreads` property to assign the maximum value. A <max> value of 0 means that there is no maximum and a new thread will be generated for a connection if there are no current threads available. This is the default. The <max> and <min> values are stored as integers, so the theoretical maximum is 2147483647 (the maximum size of an integer). But the practical maximum is determined by the machine configuration.
- To change the time that a thread should work on one session's request and check if there are waiting sessions, use the following command:

      java org.apache.derby.drda.NetworkServerControl
      timeslice <milliseconds> [-h <hostname>] [-p <portnumber>]

  You can also use the derby.drda.timeSlice property to set this value. A value of 0 milliseconds indicates that the thread will not give up working on the session until the session ends. A value of -1 milliseconds indicates to use the default. The default value is 0. The maximum number of milliseconds that can be specified is 2147483647 (the maximum size of an integer).

Parent topic: Derby Network Server advanced topics
Related concepts
Network Server security
Related tasks
Running the Network Server under the security manager
Controlling logging by using the log file
Controlling tracing by using the trace facility