Advanced Java: Multi-threading Part 14 - Interrupting Threads

preview_player
Показать описание
-------------------------------------------------------------------------------------------------------------------------------------------
Interrupting threads in Java; what are those pesky interrupted exceptions, what causes them and why are we continually handling them in Java? In this tutorial I show you an interesting method of telling your threads to terminate -- although the method we covered back in tutorial number 2 is perfectly fine for most purposes.
--------------------------------------------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Excellent tutorials. I went through all the tutorials in one day. Great Job!!!

mycricketcafe
Автор

This series is awesome! I managed to connect these concepts that have been disjointed to me all these years!

Thanks a lot!

kosgeinsky
Автор

Wonderful series of tutorials. Very informative and useful.

rasthana
Автор

Ah! Good question. Yes, wait() or sleep() throw an interrupted exception when the thread they are called in is interrupted. Your main thread will usually still be executing (since it called interrupted()) of course. It's up to you to periodically check isInterrupted() in your thread to see if it has been interrupted and decide what to do about it. Nothing happens automatically, except that sleep or wait will throw an exception when the thread is interrupted.

caveofprogramming
Автор

Hi Andrés, I don't really know of any pros or cons ... except that the flag thing can result in less code, since if you use interrupt, it might cause a sleep or a wait to throw an exception; while the flag is totally under your control. On the other hand you can't stop sleep() with a flag. So I see no huge advantage to the interrupt thing, except that being able to stop a sleep is sometimes useful.

caveofprogramming
Автор

Great work. I really impressed with your work. I go through all the videos for multi-thread and have some concrete idea about how the Java works. 

junxie
Автор

No words!!! Beautiful style of coding and clean explanation :)

sritharan
Автор

Went through all tutorials and tried simultaneously. Fantastic work - you made it look so easy..

Please do think about updating code examples with java8 versions.. it will make your code more relevant wrt today's world..

HarshChannel
Автор

Thank you for this comprehensive series of videos on threads

dianaeftaiha
Автор

Fantastic, I gone through all the videos about Threads . Kudos -John

josephselvaraj
Автор

Wonderful and extremely useful series, helped me a lot to understand threads! Thank you very much for your clear tutorials, keep up the good work! :)

magombre
Автор

thankyou so much sir!! i went through all of them and i guess ive learned java multithreading! this is so helpful

som
Автор

Thank you so much John. I tried to read these concepts from book, however they were never clear. After listening to your tutorials, I am sure the books will make more sense.
Are you going to make something for fork-join, new feature in Java 7.

amitp
Автор

Hi john .. thanks for such a great tutorial .. I have a good understanding now for this material ... can you do a tutorial .. for the fork join framework ... I am reading it .. but I can't get it right ...

WaseemSwaileh
Автор

Gracias por el tutorial, aprendi bastante.
Thanks for the tutorial, i've learn a lot.

alvarod
Автор

amazing tutorials. It really helped me in getting my concepts clear.

trustaniket
Автор

Best tutorial sequence on multithreading, whenever I need refresh I watch this

ytubenilesh
Автор

Amazing tutorials. Very well explained. Thanks for the series.

grandhirahul
Автор

It's still helpful in 2018th. Thank you !

evgenistanchev
Автор

I've just been having a debate with a friend about when to use currentThread() and what it's actual main use is. I'm coming to the conclusion that it should only really be used on Thread.currentThread (not some other thread like t1.curthread). 

Now i'm massively confused.

Do you mind explaining briefly how i should use this static method and what its main use is? I would appreciate that massively. Have gone through this playlist in its entirety and is absolutely fantastic. thank you so much! 

orbita