ThreadFactory that maintains a count of how many threads this factory has created
| Modifier and Type | Class and Description |
|---|---|
| private static class | CountingThreadFactory.RunnableWithLifeCycle
Runnable which also fires lifecycle events |
| Modifier and Type | Field and Description |
|---|---|
| private final ThreadFactory | |
| private final AtomicInteger |
| Access | Constructor and Description |
|---|---|
| public | CountingThreadFactory(ThreadFactory
the actual factory actualFactory)Constructor accepting the actual thread factory that will create the threads |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: Returns the number of threads this factory has created and currently aliveReturns the number of threads this factory has created and currently alive |
| public Thread | newThread(Runnable
a runnable to be executed by new thread instance r)Implements java. Thread to run the given runnable.
|
| private void |
| actualFactory | back to summary |
|---|---|
| private final ThreadFactory actualFactory | |
| count | back to summary |
|---|---|
| private final AtomicInteger count | |
| CountingThreadFactory | back to summary |
|---|---|
| public CountingThreadFactory(ThreadFactory actualFactory) Constructor accepting the actual thread factory that will create the threads
| |
| getNumberOfThreads | back to summary |
|---|---|
| public int getNumberOfThreads() Returns the number of threads this factory has created and currently alive
| |
| newThread | back to summary |
|---|---|
| public Thread newThread(Runnable r) Implements java. Doc from java. Constructs a new unstarted | |
| threadExecutionComplete | back to summary |
|---|---|
| private void threadExecutionComplete() | |
| Modifier and Type | Field and Description |
|---|---|
| private final Runnable | |
| private final CountingThreadFactory |
| Access | Constructor and Description |
|---|---|
| public | RunnableWithLifeCycle(CountingThreadFactory countingThreadFactory, Runnable actualRunnable)
Constructor accepting a |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| actualRunnable | back to summary |
|---|---|
| private final Runnable actualRunnable | |
| countingThreadFactory | back to summary |
|---|---|
| private final CountingThreadFactory countingThreadFactory | |
| RunnableWithLifeCycle | back to summary |
|---|---|
| public RunnableWithLifeCycle(CountingThreadFactory countingThreadFactory, Runnable actualRunnable) Constructor accepting a | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation. | |