Hi Lahiru, Working with the Thread class can be very tedious and error-prone. The executor framework has protection against crashed runnables and automatically re-create worker threads . On the other hand, as Ruwan has mentioned, it gives much more control to the programmer. therefore going with executors and executor services(Concurrent Framework) is the right way if you want to have precise control over how many threads will your program generate and their exact behavior.
[1] http://www.javaworld.com/article/2078809/java-concurrency/java-concurrency-java-101-the-next-generation-java-concurrency-without-the-pain-part-1.html Regards, Samith On Thu, Sep 24, 2015 at 1:50 PM, Ruwan Abeykoon <[email protected]> wrote: > Hi Lahiru, > I would go for option 1 (Concurrent Framework) as it gives much more > control to the programmer > e.g. > 1. Thread pooling, how many threads can be active etc, > 2. Better blocking mechanism than Trhead.join(), which blocks the caller > thread. We can make things totally asynchronous by creating another > Callable when all the parallel jobs are finished. > > Cheers, > Ruwan > > On Thu, Sep 24, 2015 at 10:35 AM, Lahiru Manohara <[email protected]> > wrote: > >> Hi All, >> >> The BPS we can define to call a methods simultaneously within the >> workflow. >> [image: Inline image 1] >> >> Same thing can be done using the java threads. There are two >> implementation available to tackle this problem. >> 1). Using java Executor interface[1] >> 2). Using runnable interface[2] >> >> [1] >> http://stackoverflow.com/questions/18162863/how-to-run-different-methods-parallely >> [2] >> http://stackoverflow.com/questions/9664036/how-to-run-two-methods-simultaneously >> >> Which option is better. WDYT. >> >> Thanks. >> >> -- >> Best regards, >> >> *Lahiru Manohara* >> *Software Engineer* >> Mobile: +94716561576 >> WSO2 Inc. | http://wso2.com >> lean.enterprise.middleware >> >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > > *Ruwan Abeykoon* > *Architect,* > *WSO2, Inc. http://wso2.com <http://wso2.com/> * > *lean.enterprise.middleware.* > > email: [email protected] > -- Best Regards Samith Dassanayake Software Engineer | Cloud TG WSO2, Inc. | http://wso2.com lean. enterprise. middleware Mobile : +947 76207351
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
