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

Description

  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.

Innovations

  • 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

Extensions

  • 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.

Applications

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
  • 下载

java design pattern -- prototype

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

java design pattern -- facade

Facade外观模式(门面模式):  为子系统中的一组接口提供一个统一接口。Facade模式定义了一个更高层的接口,使子系统更加容易使用。  Facade模式是为了降低子系统之间,客户端与实现化层...

Factory design pattern in java

What is the most usual method of creating an instance of a class in java? Most people will answer th...
  • stuShan
  • stuShan
  • 2015年05月10日 12:14
  • 544

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

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

java singleton design pattern

from: http://www.javacoffeebreak.com/articles/designpatterns/index.htmlFor those who haven'...

Java Design Pattern

Design Patter(设计模式)         一、Singleton(单例模式):表示一个类只会生成一个对象。                            ①      ...
  • xyh820
  • xyh820
  • 2012年01月28日 20:57
  • 315

Java Design Pattern: Builder

The key feature of Builder pattern is that it involves a step-by-step process to build something, i....

Java Design Pattern 2

Single Design pattern对于单例模式的理解,我将之描述为:单例模式只拥有一个实例,它的实例由自己构建,并将之提供给其它对象。 # 单例模式用于解决一个类对象频繁实例化和销毁等问题...

java design pattern

  • 2012年02月27日 15:51
  • 403KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Java Design Pattern for Concurrent Multiple
举报原因:
原因补充:

(最多只允许输入30个字)