关闭

Java Design Pattern for Concurrent Multiple

780人阅读 评论(0) 收藏 举报
分类:

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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4595159次
    • 积分:39430
    • 等级:
    • 排名:第98名
    • 原创:22篇
    • 转载:1920篇
    • 译文:0篇
    • 评论:500条
    最新评论