Topic Path: Symbol Reference > Classes > TIdSchedulerOfThreadPool Class > TIdSchedulerOfThreadPool Methods > NewThread Method
ContentsIndexHome
PreviousUpNext
TIdSchedulerOfThreadPool.NewThread Method

Initializes a new thread for a client connection task in the scheduler.

function NewThread: TIdThreadWithTask; override;

TIdThreadWithTask - Thread created for the scheduler, or Nil when a thread cannot be created.

NewThread is an overridden TIdThreadWithTask function used to create and initialize the executable task for a yarn managed by the thread-based scheduler. 

The return value for the method is a TIdThreadWithTask instance that represents the thread created for the client connection executable task in the scheduler, or Nil when a thread cannot be created. 

NewThread calls the inherited NewThread method to determine the thread priority and the maximum number of threads allowed in the thread-based scheduler. NewThread also sets the StopMode value in the thread instance to Suspend (rather than Terminate) which allows a stopped thread to be returned to the internal thread pool for subsequent use. 

NewThread is used in the AcquireYarn method when an executable thread is needed for one of the ActiveYarns managed by the scheduler. 

Use StartYarn to begin execution of the thread for a client connections' executable task. 

Use TerminateYarn to halt execution of the thread for a client connections' executable task.

Exceptions 
Description 
Raised with the message RSchedMaxThreadEx when the number of threads would exceed the value in MaxThreads
Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.