{$cfg_webname}
主页 > 外文翻译 > 计算机翻译 >

并发编程

来源:56doc.com  资料编号:5D2639 资料等级:★★★★★ %E8%B5%84%E6%96%99%E7%BC%96%E5%8F%B7%EF%BC%9A5D2639
资料以网页介绍的为准,下载后不会有水印.资料仅供学习参考之用. 帮助
资料介绍




并发编程



  面向对象提供了一个将程序划分成相互独立的模块的方法。时常还会碰到,要把程序分解开,让它的各个部分都能独立运行的问题。

  每一种能独立运行的小任务就是线程(thread)。编程的时候,可以认为线程都是能独立运行的,和拥有自己的CPU。实际上,是一些下层机制在为你分割CPU的时间,只是你没有想到罢了。这种做法能让多线程的编程变成更加简单的任务。

  一个进程(process)是一种有自己地址空间的" (self-contained)"程序。通过在不同的任务之间定时切换CPU,多任务(multitasking)操作系统营造出一种同一个时间可以有多个进程(程序)在同时运行的效果。线程是进程内部的独立的的指令数据流。一个进程能包含多个并发执行的线程。

  多线程有很多可能的用处,但大体上,你会让程序的某一部分试着联系一个专门事件或资源,你不想让它把整个程序都给阻塞了。因此,你创建一个与该事件或资源相关的线程,让它独立于主程序分开来运行。

  学习并发编程就像是进入一个新的世界,同时学习一种新的编程语言,最起码也得接受一套新的语言概念。随着绝大多数的微电脑操作系统对多线程的支持,编程语言和库也做了扩展。总而言之,多线程编程:

1. 看上去不但神秘,而且还要求一个对编程思想方法的转变

2. 其它语言对多线程的支持相似,所以理解线程就等于掌握了一种通用语言

  虽然支持多线程会让Java变成更复杂的语言,但这并不全是JAVA的错--线程狡猾。





外文原文(复印件)

      Concurrency

Objects provide a way to divide a program into independent sections. Often, you also need to turn a program into separate, independently running subtasks.

Each of these independent subtasks is called a thread, and you program as if each thread runs by itself and has the CPU to itself. Some underlying mechanism is actually dividing up the CPU time for you, but in general, you don't have to think about it, which makes programming with multiple threads a much easier task.

A process is a self-contained running program with its own address space. A multitasking operating system is capable of running more than one process (program) at a time, while making it look like each one is chugging along on its own, by periodically switching the CPU from one task to another. A thread is a single sequential flow of control within a process. A single process can thus have multiple concurrently executing threads.

There are many possible uses for multithreading, but in general, you'll have some part of your program tied to a particular event or resource, and you don't want that to hold up the rest of your program. So, you create a thread associated with that event or resource and let it run independently of the main program.

Concurrent programming is like stepping into an entirely new world and learning a new programming language, or at least a new set of language concepts. With the appearance of thread support in most microcomputer operating systems, extensions for threads







推荐资料