Broadly, JCSP provides three types of guards.
大体来说,JCSP提供了三类警卫。
JCSP handles such issues explicitly, as you'll see.
您将会看到,jcsp显式地处理这类问题。
JCSP defines two interfaces for reading from and writing to channels.
JCSP定义了两个接口用于从通道读取对象和向通道写入对象。
JCSP provides a class called PriParallel that prioritizes the processes passed to it.
JCSP提供了一个叫作PriParallel的类,可以为传递给它的进程加上优先级。
A barrier is a JCSP event that ACTS as a synchronization mechanism between multiple processes.
barrier是一个JCSP事件,可以充当多个进程之间的同步机制。
The constructs discussed thus far (first in Part 2 and now here) are the core constructs of the JCSP library.
迄今为止讨论的构造(从第2部分开始到现在这里)都是jcsp库的核心构造。
In JCSP, a process is essentially a class that implements the CSProcess interface. Listing 1 shows the interface.
在JCSP中,进程实际上就是实现了CSProcess接口的类。
There are no hidden interactions in JCSP-based programs — at each level of the network all the plumbing is visible.
在基于JCSP的程序中,没有隐藏的互交——在网络的每一级上,所有的管道都是可见的。
Because channels are an important concept in JCSP, let's make sure you understand how they work before going further.
因为通道在JCS p中是重要的概念,所以在进行下一步之前,要确定您确实理解了它们的工作方式。
See the JCSP library download (in Resources) for further documentation of these constructs, including usage examples.
请参阅JCSP库的下载 (在参考资料 中),以获得这结构造的更多文档,包括用例。
I used several working examples to demonstrate the use of essential JCSP constructs such as processes, channels, and guards.
我用了几个实例演示了基本的JCSP构造(例如进程、通道和警卫等)的使用。
Next time you find yourself considering (and perhaps shying away from) a multithreaded application design, you may want to turn instead to the JCSP library.
下次您会发现,在您自己考虑(也可能要在躲避)多线程应用程序设计时,您可能想转而采用jcsp库。
I conclude this introduction to JCSP with a simple example that demonstrates the use of JCSP guards to facilitate non-determinism in concurrent applications.
我用一个简单的示例,演示如何用JCSP警卫实现并发应用程序中的非确定性,借此总结对JCSP的介绍。
In the specific context of JCSP, an abstract class called Guard is provided, which must be subclassed by event objects that are competing for selection by a process.
在JCSP的特定上下文中,提供了一个叫作Guard的抽象类,竞争进程选择的事件必须继续它。
It USES the JCSP-provided class NumbersInt to generate a sequence of natural Numbers that are fed through the temp channel to another built-in class, called FixedDelayInt.
它用JCSP提供的类NumbersInt生成一系列自然数,通过temp通道传递给另一个叫作FixedDelayInt的内置类。
Building applications with JCSP results in clean interfaces and lack of hidden side-effects which makes the resulting product resilient to maintenance and technology changes.
用JCSP构建系统会产生干净的接口,很少有会造成产品不好维护和技术变化这类隐藏的副作用。
Note that JCSP implements process priorities in terms of the underlying thread's priority mechanism; so how the priorities actually work out depends on the underlying JVM implementation.
注意,JCSP以底层线程的优先级机制实现进程的优先级;所以优先级实际的工作方式取决于底层的JVM实现。
From here on, I use code examples to demonstrate how these and other JCSP constructs work. In Listing 2, you can see a very simple process that outputs all even integers between 1 and 100.
从现在开始,我将使用代码示例来演示这些和其他JCSP构造如何工作。
I also demonstrated some of the JCSP constructs for resolving more complex synchronization issues and briefly discussed the possibility of distributed programming with the JCSP.net package.
我还演示了一些用来解决更复杂的同步问题的JCSP构造,简要讨论了用JCSP.net包进行分布式编程的可能性。
If you've been reading along with this series from the beginning, you should agree by now that CSP is a programming paradigm worth investigating and the JCSP library a worthy addition to your toolkit.
如果您从开始就一直阅读这个系列,那么到了现在,您应当同意CSP是一个值得研究的编程范式,而jcsp库则值得您添加到工具包中。
If you've been reading along with this series from the beginning, you should agree by now that CSP is a programming paradigm worth investigating and the JCSP library a worthy addition to your toolkit.
如果您从开始就一直阅读这个系列,那么到了现在,您应当同意CSP是一个值得研究的编程范式,而jcsp库则值得您添加到工具包中。
应用推荐