| | 文章目录:返回首页--职业助手--扬智(软)第8题答案
扬智(软)第8题答案 题目: 8. Explain the concept and benefit of threads 1) On the Internet in Usenet newsgroups and similar forums, a thread is a se quence of responses to an initial message posting. This enables you to follo w or join an individual discussion in a newsgroup from among the many that m ay be there. A thread is usually shown graphically as an inital message and successive messages "hung off" the original message. As a newsgroup user, yo u contribute to a thread by specifying a "Reference" topic as part of your m essage. 2) In computer programming, a thread is placeholder information associated with a single use of a program that can handle multiple concurrent users. From the program''s point-of-view, a thread is the information needed to serve one individual user or a particular service request. If multiple users are using the program or concurrent requests from other programs occur, a thread is created and maintained for each of them. The thread allows a program to know which user is being served as the program alternately gets re-entered on behalf of different users. (One way thread information is kept by storing it in a special data area and putting the address of that data area in a register. The operating system always saves the contents of the register when the program is interrupted and restores it when it gives the program control again.) Multithreading and tasks are similar and are often confused. Some computers can only execute one program instruction at a time, but because they operate so fast, they appear to run many programs and serve many users simultaneous ly. The computer operating system (for example, Windows 95) gives each progr am a "turn" at running, then requires it to wait while another program gets a turn. Each of these programs is viewed by the operating system as a "task" for which certain resources are identified and kept track of. The operating system manages each application program in your PC system (spreadsheet, wor d processor, Web browser) as a separate task and lets you look at and contro l items on a "task list." If the program initiates an I/O request, such as r eading a file or writing to a printer, it creates a thread so that the progr am will be reentered at the right place when the I/O operation completes. Me anwhile, other concurrent uses of the program are maintained on other thread s. Most of today''s operating systems provide support for both multitasking a nd multithreading. They also allow multithreading within program processes s o that the system is saved the overhead of creating a new process for each t hread.
|
|