Java Design Pattern for Concurrent Multiple

转载 2013年12月05日 14:42:23

Java Design Pattern for Concurrent Multiple Object Operations - Illustrated in iManager Plugin development

Novell Cool Solutions: Feature
By R Sathish

Digg This - Slashdot This 

Posted: 22 Dec 2004

Problem: To concurrently process operations which involve a collection of objects, like deleting 'n' objects, updating 'n' objects.

Existing Solution: Write the code in a class, make it extend Thread and execute it. Iterate over the collection of objects, catch all exceptions.

Design Pattern: Separates application specific and language specific code.

doMooParallel executes MooCode in MooThreads
User implements MooCode and calls doMooParallel

What it achieves?

  • It works like magic in parallelizing a piece of code.
  • Using this design pattern one can embed highly efficient parallel pieces of code in their methods.
  • It completely abstracts all details of java multithreading to the developer.
  • It enables getting all exceptions in all threads in a single collection.
  • It promotes doing parallelable tasks in multiple threads... i.e. it attracts developer to make his code's execution parallel with very little design change.

Advantages over existing Threads infrastructure

  1. Serial code and Parallel execution
  2. Abstraction
  3. Genericity
  4. Get all errors in all threads in one collection
  5. Parallel execution of common code on different objects - Code once, Run concurrently with different objects - Example Delete 'n' objects concurrently


  1. Define the code to be executed in a separate class.
  2. Pass a collection of objects to be operated concurrently to design pattern.
  3. The design pattern starts a thread for every object and executes the code over that object.
  4. Design pattern collects all exceptions thrown in another collection and returns it.
  5. Design pattern waits for all threads to complete.
  6. Design pattern can be extended to use thread pools, or it can execute in single thread.


  • Serial coding and Parallel execution
  • Parallel execution of Multiple Object operations Design pattern which is language independent
  • Error handling in this design pattern- Get all exceptions in all threads in a single collection
  • Manager - Worker design pattern


  • Can be easily translated to C++ or any other Programming language which supports / needs multi threading.
  • Can be improved to use Thread pools to become more efficient.
  • Can be used as a precursor to develop more intelligent Programming languages.
  • Can be used in any domain where parallelism is needed.


Currently used in iManager plugins to talk to eDirectory

  • eDirectory - Read,Write,Delete,Create objects in all replicas for assured synchronization.
  • eDirectory - Delete multiple objects, Read multiple objects ...

Future applications

  • EJB ..Update customers all accounts, when a customers telephone number changes...
  • Distributed databases - Update the object in all replicas ...
  • Any code which can be executed concurrently for better performance. (optionally over different objects).


Design Pattern for GUI

  • 2007-12-10 12:06
  • 265KB
  • 下载

Design pattern Java tutorial

  • 2015-01-10 21:06
  • 2.39MB
  • 下载

Java设计模式中单例模式(Design Pattern):懒汉模式和饿汉模式

设计模式,是被反复使用,多数人知道,并经过分类的代码设计经验的总结。目的自然是代码的重用,理解,可靠等。 所谓单例模式,就是有些对象只需要一个,比如,配置文件,工具类,线程池,缓存,日志对象等等,在...

Design Pattern Java Companion

  • 2007-12-10 22:03
  • 2.19MB
  • 下载

java design pattern

  • 2012-02-27 15:51
  • 403KB
  • 下载

java design pattern -- prototype

原型模式: 1、定义:原型模式就是通过一个原型对象来表明要创建的对象类型,然后用复制这个对象的方法来创建更痛类型的对象。 2、原理:有两部分组成,抽象原型和具体原型。 3、使用时机:...

Java Design Pattern eBook

  • 2016-05-09 19:59
  • 1.69MB
  • 下载

Java Design Pattern

工厂模式,简单来描述就是 ,一个类拥有累死工厂的生产模式,根据用户的要求,返回指定的类型对象。