+ 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.

30th Jun 2018, 2:38 AM
harshit
harshit - avatar
3 Antworten
+ 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😊
12th Jul 2018, 10:13 PM
Arun Tomar
Arun Tomar - avatar
+ 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.
30th Jun 2018, 4:27 AM
Arun Tomar
Arun Tomar - avatar
0
ok,but what is the means of InterruptedException
1st Jul 2018, 6:18 PM
harshit
harshit - avatar