There are also some public synchronization methods: The TThread class has a constructor with a single parameter (CreateSuspended) that lets you choose whether to start the thread immediately or suspend it until later. To use threads, you always subclass TThread (optionally starting with the Thread Object of the New Items dialog box (File ^ New ^ Other) and use the features of this base class. The first thing to know about the TThread class is that you never use it directly, because it is an abstract class-a class with a virtual abstract method. Delphi provides a TThread class that will let us create and control threads. Win32 has an API to allow two procedures or methods execute at the same time. (If you don't know much about threads, read the sidebar "Working with Threads" before proceeding.) Working with Threads Now, even if making the database-related code multithreading wouldn't be easy, I'll take the excuse of this example to show you how to build a program based on blocking sockets and threads. A program like the one I've just built is nice, but it won't really scale up on a large system, because the server uses a blocking connection and the requests are processed in sequence.
0 Comments
Leave a Reply. |