java Exception | SoloLearn: Learn to code for FREE!

+2

java Exception

Why we write throws "InterruptedException "after main() if we perform garbage colllection? I know it is not necessary but I have seen it on a website.

6/30/2018 2:38:19 AM

harshit

3 Answers

New Answer

+9

harshit I take a long time to answer you. hope you dont mind.. Interrupted Exception arise when our thread is in block pool and we run interrupted method on that thread.. so that thread come out from the block pool and throw the Interrupted Exception..... there are so many way to thread to throw the interrupted exception.. note. as you know our program is also run on a thread. and gc also run on a thread... so and you know the life cycle of thread.... so in case of thread waiting in a block pool and we perform some action so it come out from the pool with interrupted exception... if you also not understand yet.. make sure you tell me😊

+4

harshit there are two type of exception checked exception and uncheck exception as you know. check exception are not forword in a calling chain but uncheck exception are... so if you want to forword the check exception used throws keyword or try catch where it call.... or atleast if you put throws keyword with main it throws the exception to jvm. and jvm used try catch to handel our exception let suppose if at running program.. an exception come and you used throws keyword. so jvm handle the exception.. and tell us why exception come and why our program closed ..... java is a robust technology.

0

ok,but what is the means of InterruptedException