Application of multithread Technology in Delphi database programming

Source: Internet
Author: User

Introduction

In the tradition, the implementation of concurrent multitasking is to run multiple processes at the operating system level, the operating system according to a certain strategy (priority, cycle, etc.), scheduling the implementation of various processes to maximize the use of all kinds of computer resources. The most basic scheduling unit in this implementation is the process at the operating system level. Because each process has its own independent operating environment (registers and address space, etc.). The coupling between process and process is poor, the granularity of concurrency is too coarse, and concurrent implementation is not easy. Therefore, unless the special needs, the general application design does not adopt this technique.

In order to overcome these problems, the process design technology of concurrent multithreading has been developed gradually in recent years. From a variety of concurrent multitasking programming languages, such as Ada, concurrency C, which are not threads, but whose basic ideas are the same, to Mach, Chorus, Solaris system, and other threading-technology-based systems, Multithreading technology has been rapidly developed and increasingly widely used. IEEE also introduced the standard posix1003.4a for multithreaded programming. In particular, a popular operating system such as Window NT and Windows 98 uses a thread as the basic dispatch unit, and its API also provides user program interfaces for threading operations. All of these will undoubtedly promote the use of multithreading technology in the design of increasingly widespread.

The concept of multithreading technology

The so-called thread (or clue, thread), which controls the flow in a single order in the program. Threads execute sequentially, in one thread, one moment at a time only by one execution point. Obviously, a program designed according to the traditional method, whether it is a single channel execution program or multiple processes executing concurrently, is composed of a single thread for each program itself.

Multithreaded programming is the process of making a single program contain multiple threads that execute concurrently. When a multithreaded program executes, there are multiple control flows running concurrently in the program's corresponding process, that is, multiple threads with concurrent execution. There are multiple control flows that are executed concurrently in a process, rather than multiple control flow one by one scattered across multiple processes, which is a distinct part of multithreaded design and concurrent multiprogramming programming. This determines that although there are many conceptual similarities between the two, but the implementation of the method is completely different.

Figure 1 The relationship between processes

Figure 2 the relationship between threads

Figure 1 and Figure 2 respectively indicate the breakdown of a task by two concurrent processes and two concurrent threads. Compare the processes and processes in these two graphs, the relationship between thread and thread can be seen, the relationship between the process is relatively distant, each process is in its own unique address space to execute, not only registers and stacks are unique, dynamic Data heap, static data area and program code are independent of each other. The relationship between threads is much tighter. Although each thread has a unique register and stack for keeping its own flow of control, because each thread belongs to the same process, they share the same address space, so the dynamic heap, the static data area, and the program code are common to each thread.

Many multitasking operating systems limit the maximum number of processes a user can have, such as a typical version of 20 for many UNIX versions, which is far from enough for many concurrent applications. But for multithreading technology, there is no such number limit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.