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

《Concurrent Programming in Java: Design Principles and Patterns》Second Edition

个人编写程序也算有些年头了, 多线程并发程序也编写过, 但都是些无关大局的东西, 最近在写一个中间件, 感觉自己在并发程序设计方面的知识储备不足, 才想起看这本书来. 书有些老, 代码风格也不合我的口...
  • saintxzm
  • saintxzm
  • 2007年08月09日 10:26
  • 1545

说Hand-over-hand lock: 通读Concurrent Programming in Java: Design Principles and Patterns (1)

网络是个好东西,想学什么想用什么,一搜就基本能找到, 有时由于输入的关键词不佳, 难找到合适的结果, 有时干脆就是没有相关的网页(或者是问题太简单), 这样的时候自已难免会多花时间琢磨, 这些琢磨的结...
  • revv
  • revv
  • 2008年03月13日 10:12
  • 1670

java设计模式大全 Design pattern samples in Java(最经典最全的资料)

Design pattern samples in Java.Build status:IntroductionDesign patterns are formalized best practice...
  • changemyself
  • changemyself
  • 2015年06月19日 13:10
  • 10411

JAVA设计模式之 简单工厂模式【Simple Factory Pattern】

一、概述 er、适用场景
  • l416112167
  • l416112167
  • 2014年10月18日 21:48
  • 2653

java设计模式(Design Patterns)

设计模式(Design Patterns)                                   ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用、...
  • zhihui1017
  • zhihui1017
  • 2015年11月09日 10:54
  • 1404

Java设计模式之适配器模式(Adapter Pattern)

Adapter Pattern的作用是在不改变功能的前提下转换接口。Adapter分为两类,一类是Object Adapter, 另一类是Class Adapter。由于Class Adapter的实...
  • tracker_w
  • tracker_w
  • 2014年06月17日 03:39
  • 2481

设计模式之---单例模式(Singleton Design Pattern)

场景 对象只要利用自己的属性完成了自己的任务.那该对象就是承担了责任。 除了维持了自身的一致性,该对象无需承担其他任何责任。 如果该对象还承担着其他责任,而其他对象又依赖于该特定对象所承担的贵任...
  • u010878994
  • u010878994
  • 2016年04月26日 01:19
  • 585

设计模式 - 模板方法模式(template method pattern) 详解

模板方法模式(template method pattern) 详解本文地址: http://blog.csdn.net/caroline_wendy模板方法模式(template method pa...
  • u012515223
  • u012515223
  • 2014年06月18日 19:31
  • 2091

几本Design Pattern的书

大话设计模式设计模式--基于C#的工程化实现及扩展(china-pub 首发) First head Design Pattern设计模式之禅...
  • tuwen
  • tuwen
  • 2011年03月06日 11:51
  • 979

C++版的Head First Design Pattern

       前 些天从sourceforge上down下一个C++版的Head First Design Pattern,一直都没有仔细看过,也不知道HeadFirstDesignPattern是一...
  • iinel
  • iinel
  • 2007年11月16日 10:13
  • 1580
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Java Design Pattern for Concurrent Multiple
举报原因:
原因补充:

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