Java多线程开发简化类库 SlicedBread

jopen 13年前
     SlicedBread 是一个用于简化 Java 多线程程序编写的类库。    <p>SlicedBread is a library that makes it simpler to program multithreaded applications in Java. It does so by doing away with "classic" multithreaded staples - that is, shared state using thread-safe objects, locks and synchronizers - versus a set of single-thread processes that send and receive immutable messages. In a sense it is inspired by Erlang's messaging system. In another, the over 400 rich pages of "Java concurrency in practice" show how hard it is to write and debug a good-mannered multithreaded application in Java.</p>    <p>SlicedBread has been used in production systems for quite a bit of time now with no major issues, so I thought it was something that could benefit the community at large and I'm sharing it.</p>    <p>SlicedBread is licensed under the LGPL.</p>    <h2>Sample application</h2>    <p>The sample application is available at under the sources as:</p>    <hr />    <pre><code>    ch.loway.oss.sbDemos.helloWorld.HelloWorld</code></pre>    <hr />    <p>It basically spawns a couple of threads and sends each a simple message so that one prints "Hello" and the other "World".</p>    <p>The output looks something like:</p>    <hr />    <pre><code>    Hello world starting      (Thread A#2) I am thread Thread A (created by Main)      (Thread A#2) PRINTING: Hello      (Thread A#2) Now Stopping      (Thread B#3) I am thread Thread B (created by Main)      (Thread B#3) PRINTING: World      (Thread B#3) Now Stopping      Message found: F:Thread A#2 T:Main#1 - ProcessStarted      Message found: F:Thread A#2 T:Main#1 - ProcessEnded       Message found: F:Thread B#3 T:Main#1 - ProcessStarted      Message found: F:Thread B#3 T:Main#1 - ProcessEnded </code></pre>项目地址:    <a href="/misc/goto?guid=4958197629414314947" target="_blank"></a>