Hi Java Dudes,
The most confusing, critical programming in Java Programming is Thread Programming.
Even in Stand-alone running app, it needs deep understanding of JVM, Threads, and design analysis to develop app. In J2EE environment it is very pathetic, tedious job to manage them.
So we have to knwo some understand them B4 coding.
Here i am giving a overview on Thread Management in stand alone and Sprign based J2EE app.
If you need control and manage threads in
Stand alone Application :---
+ Better use "
The most confusing, critical programming in Java Programming is Thread Programming.
Even in Stand-alone running app, it needs deep understanding of JVM, Threads, and design analysis to develop app. In J2EE environment it is very pathetic, tedious job to manage them.
So we have to knwo some understand them B4 coding.
Here i am giving a overview on Thread Management in stand alone and Sprign based J2EE app.
If you need control and manage threads in
Stand alone Application :---
+ Better use "
java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,
TimeUnit unit,BlockingQueue ;Runnable workQueue)
Give your Task you want to run Asynchronously.
Set Pool Size Maximum to limit the number of threads.
Set the Maximum alive time for threads to live in this.
TimeUnit unit,BlockingQueue ;Runnable workQueue)
Give your Task you want to run Asynchronously.
Set Pool Size Maximum to limit the number of threads.
Set the Maximum alive time for threads to live in this.
corePoolSize
- the number of threads to keep in the pool, even if they are idle.maximumPoolSize
- the maximum number of threads to allow in the pool.keepAliveTime
- when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.unit
- the time unit for the keepAliveTime argument. (Seconds , or minutes )workQueue
- the queue to use for holding tasks before they are executed.
This is the ultimate way for Thread management in Java Apps, Swing based Apps, Stand alone Batch jobs .
What about J2EE ?
I dont know about otherframeworks like (JSF, Struts, Blah blah.....), But Spring the provides lot of Bean Drivenable Thread Executors :
I suggest to use the ultimate one :
ThreadPoolTaskExecutor.
Properties to be set same as above .
Declare it as a bean and use wher eu want to spawn threads.
Thanks
Balaji.Mathu@gmail.com
No comments:
Post a Comment