Whats amazing is that you make even complex concept interesting and easy to understand :)
@mustafakamalsirajudeen81336 жыл бұрын
Excellent. You are touching the complicated areas to understand, but explaining in simple manner. Appreciate.
@DefogTech6 жыл бұрын
Thanks much! I'm very happy and motivated that's it helping folks.
@thecosmicantinatalist5 жыл бұрын
That crow needs a task.
@algorithmimplementer4153 жыл бұрын
Haha .. I just noticed it now. Maybe the crow is doing its task.
@rishirakh13 жыл бұрын
Now I can't ignore cow cow 🙄😭
@pradeepkpanga Жыл бұрын
Savage
@meershahidmanzoor2 ай бұрын
He's doing his asynchronous task
@msteja2 жыл бұрын
Best concurrency/multithreaded insights playlist ever found!!
@somasundaramvalliappan38514 жыл бұрын
the videos are amazing, the most interesting aspect is you connect cpu cores caches and the threads, hardware to software, great sir, please continue this you are really a guru thanks👍
@aftabshaikh200 Жыл бұрын
Explanation was very good. I have one opinion, I might be wrong here but I don't think SingleThreadedExecutor executes task in sequential manner. It might pick up the tasks in order but it doesn't mean that it will pick it up after completing the first one. Because, in case first thread is doing some IO operation, the CPU and the thread will start processing the next task.
@pramalvi9 ай бұрын
You are right. If one of the I/O task is waiting then single thread can continue to execute other tasks while waiting for the I/O task to complete. FIFO ordering is not guaranteed unless all tasks are CPU based.
@sathyendrana38806 жыл бұрын
Explanation is very clear. I have understood the Java threads.
@shekhar_20144 жыл бұрын
This is what I call as an Excellent Explanation .. HatsOff !!! 🤟
@sumitbabel54154 жыл бұрын
Honestly you are exceptionally awesome, such an easy explanation style. Hats off
@dilipsutradhar36736 жыл бұрын
highly detailed sessions great work.
@adityanehra6 жыл бұрын
Explanation is very good Sir. Is that a crow in background !!! :)
@DefogTech6 жыл бұрын
Thank you! Yes, unfortunately it is a crow.. I wasnt paying attention that day... Subsequent videos have better audio :)
@afeesps22995 жыл бұрын
lol !!
@chinmayasdora21265 жыл бұрын
Great explanation.. simple and easy to grab and a quick bite to get a very holistic view about the executors framework. I have watched this and some other videos of this series and are really good. Just to add another difference b/w a "fixed-size thread pool" and a "single-threaded thread pool" is that in case of a "fixed-size thread pool", you can still update/re-configure the pool size set in the constructor later on using the setMaximumPoolSize() method of the ThreadPoolExecutor class.
@jaleelpasha33019 ай бұрын
Introduction: - The video discusses the different types of thread pools provided by Java's `ExecutorService`. Thread Pool Types: 1. Fixed Thread Pool: - Has a fixed number of threads. - All submitted tasks are stored in a blocking queue. - Threads fetch and execute tasks sequentially. - Ideal for CPU-intensive tasks. 2. Cached Thread Pool: - Does not have a fixed number of threads. - Uses a synchronous queue to hold tasks. - Creates threads as needed and can kill idle threads. - Suitable for IO-intensive tasks. 3. Scheduled Thread Pool: - Used for scheduling tasks to run after a certain delay or at fixed intervals. - Tasks are stored in a delay queue. - Provides methods for scheduling tasks once, at fixed rates, or with fixed delays. 4. Single Threaded Executor: - Similar to fixed thread pool but with only one thread. - Ensures tasks are executed sequentially. - Useful for tasks that require strict sequential execution. Summary: - Java's `ExecutorService` provides various types of thread pools for managing tasks efficiently. - The choice of thread pool depends on the nature of tasks, such as CPU-intensive or IO-intensive, and the scheduling requirements. - Understanding the characteristics of each thread pool helps in selecting the appropriate one for different scenarios.
@proplayeriguess4 жыл бұрын
Excellent explanation Deepak - request you to continue creating more and more videos covering all the major aspects like Collections - DS etc, Great work keep it up :) And thanks a ton !!
@sambhavi6141Күн бұрын
Amazing explanation, great playlist for clearing concepts!!
@mayurdhande87125 жыл бұрын
I really liked the status bar at the bottom of your video.
@mostinho73 жыл бұрын
Done thanks Types of thread pools 1. Fixed thread pool 2. Cached thread pool - dynamically creates and terminates threads based on the number of tasks being submitted and wether there are idle threads (frequency of tasks being submitted) 3. Scheduled thread pool - uses a delay queue to keep the tasks, the tasks are not kept sequentially based on when they are submitted, but instead based on when they need to run ScheduledExecutorService .schedule(...) for running one after delay .scheduleAtFixedRate(...) running every x seconds .scheduleWithFixedDelay(...) schedule and wait x seconds after task completion 4. Single threaded executor - to ensure tasks are run in order
@mahendharkhedhar78876 жыл бұрын
wow awesome explanation
@DefogTech6 жыл бұрын
Thank you sir!
@jingli21684 жыл бұрын
I think one thing need to clarify is required between scheduleAtFixedRate and scheduleWithFixedDelay 1) The fixedRate run periodically, even though the last same execution is not finished, the pool will arrange another thread to proceed, so in this case there are two threads execute the same operation. 2) The fixedDelay will wait the last same operation to finish and then delay say 10 seconds to restart the same operation.
@aditydud4 жыл бұрын
Complicated theory but you explained it very nicely and now it seems easy to implement.Thanks a ton
@vivekdarji64404 жыл бұрын
Nice Explanation of critical functionalities in simple way. Thank you !
@avinashgarg73702 жыл бұрын
God level explanation! Thank you.
@rajdipbhattacharya19053 жыл бұрын
brilliant dude...keep the good work going
@e.ch.vidyasagarkorada89374 жыл бұрын
Thank you for tutorial it's very helpful to understand in detail Please explain about Threadpoolexeuter constructor Min Max Blookingqueue Exception Up to my knowledge Thanks in advance Expecting soon
@SBala-xk6lr4 жыл бұрын
Great vid ! Clean , clear & crisp :)
@rabiunislam93023 жыл бұрын
Very clear explanation. Keep it up.
@alokdeshpande55175 жыл бұрын
Crisp clear and precise 👍👍👍
@shwetatiwari52653 жыл бұрын
What is a better idea - having multiple SingleThreadPools or multiple threads ?
@johncerpa37823 жыл бұрын
Thank you for making this series of videos
@pankajpandey28823 жыл бұрын
Your narration is very good 👍
@navendugupta27654 жыл бұрын
Thank you for the video. It solved all my doubts.
@gavravdhongadi98244 жыл бұрын
Lucky that I found this channel
@hueynguyen4 жыл бұрын
Amazing explanation! I love ur videos.
@johnjordandionisio94023 жыл бұрын
This is brilliant. Thank you for this!
@krissling44976 ай бұрын
great content brother
@sadabhasan82186 жыл бұрын
effective and sort video, sir you are dammed good, thanks and good blase you.
@DefogTech6 жыл бұрын
Thank you very much!
@lzhu126 жыл бұрын
Thank you very much.
@duckfine68374 жыл бұрын
Pretty good video, well explained
@rishikumar28004 жыл бұрын
Hi. Great explanation. Went directly into mind. One query. There should be some way to stop the given tasks like for ScheduledatFixedRate right. If i want to exexute a task with rate of 10 and it should end after 50 executions.
@rohitsolanki64213 жыл бұрын
Clear and concise explanation!However,I have some doubts.What is the difference between a Singlethreaded pool and a Fixedpool with single thread? Also does SingleThreaded pool guarantee the execution of tasks in FIFO order?
@DefogTech3 жыл бұрын
Both Singlethreaded pool and a Fixedpool with single thread are the same. Internally SingleThreadPool used normal FixedSizedPool. Yes, thats correct, SingleThreadedPool will ensure FIFO order of execution.
@rizwansworld3 жыл бұрын
Thank you so much for the explanation!
@dineshchandgr3 жыл бұрын
hi. which thread pool we configure? Is it tomcat server threads or executor thread pool?
@GydenKnight2 жыл бұрын
Great video, that bird in the background is making a lot of noise, looks like it also want to learn what you are teaching 🤣😁
@ayushjain755511 ай бұрын
One question in case of newSingleThreadExecutor, there will no multithreading right?
@naragoud4284 жыл бұрын
Explained very well .thanks
@koushikdeb78743 жыл бұрын
Great work .. but I think the crow was pointing out one mistake its "scheduleWithFixedDelay" not "scheduleAtFixedDelay" as shown in slide
@manishmanghwani7313 жыл бұрын
Thank you for detailed explanation. Although its 3 years old video, but if you get some time, kindly review: Is Delay Queue same as priority queue? Are there in retry options for Single Threaded Executor Service. Suppose the task 1 keeps on failing and we want to retry it just for n number of times and after that Task 2 should be tried.
@simonbaker99094 жыл бұрын
Thank you very much for this clear explanation. I would like a little more detail on "scheduleAtFixedRate" method to clarify that if the run time of the task exceeds the rate period, is that an error or does the task simply start immediately again (I assume the latter).
@DefogTech4 жыл бұрын
FixedRate scheduler doesn't check finish times of the job, it will keep triggering new ones. The fixedDelay one will wait Post a job's completion before triggering next one
@simonbaker99094 жыл бұрын
@@DefogTech Does triggering mean a new thread, or just that it is ready to go immediately when other run finishes?
@DefogTech4 жыл бұрын
@@simonbaker9909 Depends on the threadpool size. If size is greater than 1, it will assign a new thread. So both tasks will overlap (will run in parallel)
@suman63274 жыл бұрын
@@DefogTech Really thanks for taking out time to explain such queries.
@ravikumarmanepalli74566 жыл бұрын
Excellent
@ankittikna1232 жыл бұрын
Hi For a single threaded executor,do we have another advantage than actually running sequential task on a different core ,since such scenario can be achieved sequentially on the main thread as well I have understood it to be helping in a non blocking sequential execution of ordered tasks only
@rohitkishore123 жыл бұрын
So singleThreadExecuter is sequential execution without any parallelism right?
@suman63274 жыл бұрын
Really thanks for putting up such high quality stuff. Coming to ScheduledThreadPool, is DelayQueue actually PriorityQueue - prioritizing the tasks based on execution time ??
@DefogTech4 жыл бұрын
no the implementation is different for both, so its a distinct data structure
@bvinodmca Жыл бұрын
very nice, thanks so much
@shaliniritti5811 Жыл бұрын
It is just osm!!!!!
@rajsekharmahapatro3 жыл бұрын
What is the difference between a fixedpool of size 1 and a singlethread pool? Technically are they both same?
@AmandeepSingh-sx9ke5 жыл бұрын
Good work!!! Please make more videos on critical topics that could help us to code better Thank you 😊🙏🏻😇
@hemanandn3 жыл бұрын
Hi, can you also create and post videos covering data structures and big (O) notations please.
@pranavprabhu6983 жыл бұрын
Can you help me with question. Create 15 fix threads that will initialise arraylist with 1000 integer.
@amitgupta72285 жыл бұрын
Hi could you please provide the video on Transactions Management with complete example and scenarios
@rahulgoti38646 жыл бұрын
Awesome!! Thank You
@rewariaditya4 жыл бұрын
Crows.. sorry .. Bows ..for the explanation :)
@vikram852285224 жыл бұрын
What is diff with fixthread pool with size 1 and single threaded executors
@DefogTech4 жыл бұрын
No difference.. they are the same.
@VishalGupta-vt9bz4 жыл бұрын
Hi Sir.. For newCachedThreadPool you have told theoretically it will create number of thread max upto number of task. But I have check it will exceeds.
@TravelWithRabindra5 жыл бұрын
Nice explanation. Thank you.
@deeproy72923 жыл бұрын
not sure where to use single Threaded executor. apparently its better to use a loop for the sequential task execution scenario
@crazycom7819 Жыл бұрын
Nice explanation
@vijaymishra42324 жыл бұрын
very nice explanation
@TheNeethz5 жыл бұрын
What are some of the use cases in which cached thread pool is used?
@adsd73493 жыл бұрын
Brilliant
@vaibhavsawant206 жыл бұрын
Very nice
@nitinkumar154 Жыл бұрын
Hello Sir, Can you please explain where we are using the blocking queue here for task submission? or is it internally from java that the submitted task will be stored in the blocking queue and will be executed by the scheduler one by one?
@DefogTech Жыл бұрын
For standard executors the blocking queue is managed internally. For custom executors we can create one and supply it from outside
@shobhitmittal774 жыл бұрын
Thank you for the clear explanation. I have a doubt - isn't the type 4 - "Single threaded executor" same as single threaded application. After all, everything will run in sequence..
@DefogTech4 жыл бұрын
yes, but you could have multiple pools in your application right? some can be multi-threaded some can be single-threaded. So at an application you still have many threads running concurrently.
@shobhitmittal77874 жыл бұрын
@@DefogTech oh right, Thanks..
@monakumari65214 жыл бұрын
@@DefogTech i am still confused that what is the need for single thread executor? Can you please give some specific example.
@AyushSharma-ux4fk3 жыл бұрын
I would be great if you could share the slides too.
@vardhamankothari34504 жыл бұрын
Was singlethreadedexexutor really required I mean I don't see what benefit it provides over traditional method ?
@AnupSingh1543 жыл бұрын
I am facing an issue, my main program is not terminating after completing the execution, why? My program is same as above.
@taufikpirjade59834 жыл бұрын
You are amazing !
@mritunjayyadav37884 жыл бұрын
really like your videos , but I have one question , in case of Single Threaded Executor why thread pool is using blocked queue , if there is only one thread a normal queue will work the same way right ?
@venkateswarank11453 жыл бұрын
Answer for your question is already addressed below
@ShaunYCheng6 жыл бұрын
good explanation thanks
@DefogTech6 жыл бұрын
You're welcome!
@nagendrasai39465 жыл бұрын
@DefogTech Just a doubt!. Here in tha case of SingleThreadedExecutor, since only one Thread is there, no need of BlockingQueue right? normal Queue is sufficient.
@DefogTech5 жыл бұрын
Still need blocking queue, even though there is only 1 queue taking elements, there are 1 or more threads adding elements from outside to ExecutorService.. so it still requires thread safe queue
@nagendrasai39465 жыл бұрын
@@DefogTech Thank You for making such great videos on Threading.
@harshpalsingh1145 Жыл бұрын
What about WorkStealingPool?
@raidtheferry8 ай бұрын
lmao 2:10 hope u got that glass cleaned up
@Shubham-zm9xj2 жыл бұрын
Thanks
@6365bharath4 жыл бұрын
If you can't control the number of threads used in a cached thread pool how does it figure out the number of threads? Does it assign threads based on the CPU Cores?
@DefogTech4 жыл бұрын
It's based on incoming requests (runnable or callable). It will create a thread for each new request if existing ones are busy.
@sumitshelar28836 жыл бұрын
In case of fixed thread pool what will happen exception occurs or the thread gets interrupted, will it impact the assigned pool size
@DefogTech6 жыл бұрын
If for any reason a thread dies, threadpool will replace it with another thread.
@tarunkundhiya51966 жыл бұрын
Thanks Defog for such a nice explanation . One question why does SingleThreadedExecutor needs a Blocking Queue ? [since there is only one thread]
@DefogTech6 жыл бұрын
Exactly, since it had only one thread, what happens if you submit multiple tasks while it is already using that thread to execute a task. It needs to save the tasks somewhere so that it can pick them up later when threas is free
@tarunkundhiya51966 жыл бұрын
@@DefogTech A queue would definitely be needed. Actually i meant why i blocking one.
@DefogTech6 жыл бұрын
@@tarunkundhiya5196 ah, good point!! Its a single generic implementation (same class for SingleThreadedExecutor vs FixedThreadPool), thus the blocking queue. So for pulling items out of queue there is single thread but I am wondering what about other thread which pushes into the queue (and what if there are multiple threads which submit the tasks), how to coordinate between these conflicts. I am not sure if normal queue will work since one thread is adding and other thread is removing from the queue.
@fatihmehmetkose2 жыл бұрын
Thanks!
@nenadg36655 жыл бұрын
Does SingleThreadedExecutor has its own constructor or we've to use fixedThreadPool and assign to it just one single thread?
@DefogTech5 жыл бұрын
Generally we always use static factory methods of Executors class. There are some subtle differences between single-threaded and fixed-threadpool of size 1
@nenadg36655 жыл бұрын
@@DefogTech Ok, Now I see it. But in Your video there is no code snippet for static factory method for singleThreadedExecutor, only for fixed, cached and scheduled thread pools so I thought there is no such method.
@DefogTech5 жыл бұрын
@@nenadg3665 Ah, my bad.
@puneetja5 жыл бұрын
I have a scenario where I need to convert around 50000 images to PNG format and then upload them to Box (using Java API's). Performing it sequentially is taking huge time. Here is what I'm thinking: I can create two threads. One will generate images and another will upload images. I will also create a list in which I will keep adding the image paths. Once the list has 100 (just an example) items, I will upload them and re-initialize the list to empty. Now if I wait for all 100 images to be uploaded and then start generating next set of images (because I'm re-initializing the list to empty), then there is no use of having multiple threads. Should I have two lists? Thread1 will generate the first 100 images. Once done, Thread2 will start will start uploading and at the same time the first thread will start generating another set of images to list 2 and so on.. I'm not sure if this approach is efficient or will work. Any suggestions/advise?
@DefogTech5 жыл бұрын
Is there a limit for box API? If not, then just create a thread pool of say 10 threads and submit all tasks - 50000 - simultaneously. Let the threading be handled by executor service. To optimize more have 2 thread pools, one of size N where N is number of CPU cores for image generation task which is CPU intensive, and second pool of size 20 or so for image uploads which is IO tasks
@puneetja5 жыл бұрын
@@DefogTechThanks for your response. There is no limit for Box. So how would I manage generation and upload? I mean I need to wait until image(s) has/have been generate. How would I maintain that?
@DefogTech5 жыл бұрын
@@puneetja create 2 pools, when submitting the image generation tasks to CPU-pool, pass them a reference (in constructor) of the IO pool. So once the images are generated, within the task, create a new upload image task, and submit it to IO pool. This way you dont have to many any queues or threading or locks.
@puneetja5 жыл бұрын
@@DefogTech Okay and this would be in batches. For example, once 500 images are generated then start uploading them and side by side start generating next set?
@DefogTech5 жыл бұрын
Why batch them? Just submit 50000 tasks. Its not a big number. If thread pool size (CPU count) is 10, it will automatically become batch size of 10. All other tasks will be stored in queue. Thats the beauty of it, we dont need to worry about that all.
@freemeplzplz5 жыл бұрын
What is the use case of a single threaded executor?
@DefogTech5 жыл бұрын
As a monitoring thread, or when only single core CPU is available, or when your use-case demands items to be processed in same order as they arrive.
@arpitkashyap16 жыл бұрын
How does in the scheduled pool, delay queue submit the task to the actual thread.(It search for free thread/ already every task is assigned to a thread/or something else)?
@DefogTech6 жыл бұрын
It's other way around. Threads will keep polling for tasks from delay queue like normal thread pool, but delay queue only shows tasks once their time has expired.
@mahmoudelsonbati86734 жыл бұрын
perfect
@devdeeds Жыл бұрын
Wow
@afagund4 жыл бұрын
My attention was all on the crow at certain point.
@Hemantkumar79906 жыл бұрын
good video but the crow is very consistent in the background :)
@DefogTech6 жыл бұрын
Sorry about that. This is my earlier video. These days I take special care to record only when background noise is less.
@manishsrms6 жыл бұрын
Thought it (Crow sound) was bit irritating but your explanation was superb. Thanks for sharing your knowledge :)
@kzu89765 жыл бұрын
rofl "consistent"
@vaibhavchhabra8003 жыл бұрын
Too many crows in your area :P
@jainprateek9042 жыл бұрын
Am I the only one who is hearing crow sound
@DefogTech2 жыл бұрын
no you are not the only one, there are lot of comments about the crow :)