# Class Acceptor<U>

java.lang.Object
org.apache.tomcat.util.net.Acceptor<U>

Type Parameters:
  `U` - the type of the socket

All Implemented Interfaces:
  `Runnable`

Direct Known Subclasses:
  `Nio2Endpoint.Nio2Acceptor`

public class Acceptor<U> extends Object implements Runnable
Acceptor thread that accepts incoming connections.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`Acceptor.AcceptorState`
States of the acceptor lifecycle.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Acceptor.AcceptorState`
`state`
Current state of the acceptor.

## Constructor Summary

Constructors
Constructor
Description
`Acceptor(AbstractEndpoint<?,U> endpoint)`
Constructs a new Acceptor.

## Method Summary

Modifier and Type
Method
Description
`final Acceptor.AcceptorState`
`getState()`
Returns the current state of the acceptor.
`protected int`
`handleExceptionWithDelay(int currentErrorDelay)`
Handles exceptions where a delay is required to prevent a Thread from entering a tight loop which will consume CPU and may also trigger large amounts of logging.
`void`
`run()`
`void`
`stopMillis(int waitMilliseconds)`
Stops the acceptor, optionally waiting for it to finish.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### state

protected volatile Acceptor.AcceptorState state
Current state of the acceptor.

## Constructor Details

### Acceptor

public Acceptor(AbstractEndpoint<?,U> endpoint)
Constructs a new Acceptor.

Parameters:
  `endpoint` - The endpoint associated with this acceptor

## Method Details

### getState

public final Acceptor.AcceptorState getState()
Returns the current state of the acceptor.

Returns:
  The current acceptor state

### run

public void run()

Specified by:
  `run` in interface `Runnable`

### stopMillis

public void stopMillis(int waitMilliseconds)
Stops the acceptor, optionally waiting for it to finish.

Parameters:
  `waitMilliseconds` - The number of milliseconds to wait for the acceptor to stop

### handleExceptionWithDelay

protected int handleExceptionWithDelay(int currentErrorDelay)
Handles exceptions where a delay is required to prevent a Thread from entering a tight loop which will consume CPU and may also trigger large amounts of logging. For example, this can happen if the ulimit for open files is reached.

Parameters:
  `currentErrorDelay` - The current delay being applied on failure
Returns:
  The delay to apply on the next failure