tag:blogger.com,1999:blog-8712770457197348465.post8795843405723064028..comments2024-03-28T02:47:19.159-07:00Comments on Javarevisited: How to create Thread Pool in Java using Executor Framework - Example Tutorialjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8712770457197348465.post-83302597763917073372020-03-09T07:41:55.030-07:002020-03-09T07:41:55.030-07:00Hello @Anonymous, there are a lot of concept there...Hello @Anonymous, there are a lot of concept there, let's go one by one<br />1. for 1000 request you don't need 1000 thread. Ideally framework create threads for you but that is controlled with some configuration. <br />2. For sync processing, one thread take request and complete until data is stored into DB And response is returned to client. In async, it hand-over to another pool of javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-46753016225801525512020-03-08T09:15:25.584-07:002020-03-08T09:15:25.584-07:00I have very generic question: Can we use threads f...I have very generic question: Can we use threads for CRUD(especially write operations) using executor service etc? I have not seen any enterprise level implementation for the same. In normal web applications also (developed using Spring MVC,JPA etc) when we get thousand of requests at a time, does Framework internally spawns the thread? or we should use some threading and synchronization Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-77351997024291621172015-08-30T06:23:15.316-07:002015-08-30T06:23:15.316-07:00@Sapna Uniyal
Two factors
- load, how much messag...@Sapna Uniyal<br />Two factors <br />- load, how much message you are receiving per second<br />- number of CPU to avoid thread context switch<br />javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-29573533495279027752015-08-24T22:44:48.932-07:002015-08-24T22:44:48.932-07:00How to decide the threadPool size? What are the fa...How to decide the threadPool size? What are the factors(memory, processor, task incoming rate to be processed by the worker threads) to be considered when we decide the threadPool size?Anonymoushttps://www.blogger.com/profile/02820685141805233894noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-68352428121023345122014-07-30T12:23:37.959-07:002014-07-30T12:23:37.959-07:00import java.util.concurrent.ExecutorService;
impor...import java.util.concurrent.ExecutorService;<br />import java.util.concurrent.Executors;<br />import java.util.concurrent.TimeUnit;<br /><br />class Task implements Runnable {<br /> private int id;<br /><br /> public Task(int id) {<br /> this.id = id;<br /> }<br /><br /> public void run() {<br /> try {<br /> //Thread.sleep(10000);<br /> System.out.println(Thread.currentThread().getName() + Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-56866807995084369882014-05-13T21:26:48.627-07:002014-05-13T21:26:48.627-07:00what will happen if one of the thread in thread po...what will happen if one of the thread in thread pool throws exception.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-61354695774515091302013-08-22T05:38:36.107-07:002013-08-22T05:38:36.107-07:00Thanks Javin, very nice article, this is really wh...Thanks Javin, very nice article, this is really what I was looking from many days about executor framework. Good job done. Best of luckwiserhawkhttps://www.blogger.com/profile/08218891935180917324noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-85785512664470793602013-07-31T20:35:56.116-07:002013-07-31T20:35:56.116-07:00Don't forget to call service.shutdown() on Exe...Don't forget to call service.shutdown() on ExecutorService. Also why @Override on the run() gives a compile error.vineetnoreply@blogger.com