关于 delphi 写服务器程序的疑问,该如何解决

关于 delphi 写服务器程序的疑问
delphi 帮助文档 关于 Service threads(服务线程) 下面两段内容

Each service has its own thread (TServiceThread), so if your service application implements more than one service you must ensure that the implementation of your services is thread-safe. TServiceThread is designed so that you can implement the service in the TService OnExecute event handler. The service thread has its own Execute method which contains a loop that calls the service's OnStart and OnExecute handlers before processing new requests. 

Because service requests can take a long time to process and the service application can receive simultaneous requests from more than one client, it is more efficient to spawn a new thread (derived from TThread, not TServiceThread) for each request and move the implementation of that service to the new thread's Execute method. This allows the service thread's Execute loop to process new requests continually without having to wait for the service's OnExecute handler to finish. The following example demonstrates.

这段话的大概意思是说:

每个服务都有它自己的线程(TServiceThread),所以如果一个服务器程序实现了多于两个服务的话,就要考虑线程安全了.service thread 有自己的Execute方法,在该方法中有一个循环,以重复调用服务的OnStart和OnExecute两事件的处理程序,这样,通过在OnStart和OnExecute两事件的处理程序中写代码就可以实现这个程序.

因为服务器程序可能接受到很多服务请求,并且处理每个请求的时间可能很长,所以对于每一个请求,通常会用一个新线程(继承自 TThread而非继承自TServiceThread)来处理,在这个新线程的onexecute写服务的实现代码,这样更有效率.采用这种方法,服务线程就可以持续处理新请求,即不必等到处理当前请求的service OnExecute的处理过程返回后,再处理下一个请求.下面有一个例子说明这个问题.

下面的例子是这样的:
---------下一楼继续----------

------解决方案--------------------
探讨
procedure TService1.Service1Start(Sender: TService; var Started: Boolean);
begin
SparkyThread := TSparkyThread.Create(False);//启动的时候创建一个新线程,如果每次处理这儿请求,都新建一个SparkyThread对象,岂不是重复创建了么? Started := True;
end;

------解决方案--------------------
Because service requests can take a long time to process and the service application can receive simultaneous requests from more than one client, it is more efficient to spawn a new thread (derived from TThread, not TServiceThread) for each request and move the implementation of that service to the new thread's Execute method。

当有客户端请求服务时,这是IdThreadMgrPool应该做的事情。新spawn一个线程,做相关工作!