Java Design Pattern for Concurrent Multiple

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值