I have a main thread in android and it has spawned a child thread(an intentService but it doesn't really matter its just a thread). Lets say the child thread gets a uncaught null pointer exception then my question is does the main thread die or only the child thread ? can the process continue ?
Asked
Active
Viewed 597 times
0
-
3There is no parent-child relationship in the context of executing a thread. – Sotirios Delimanolis Aug 27 '14 at 00:21
-
i know but what happens to the process, can it continue then ? does the JVM halt the program and crash or does it continue – j2emanue Aug 27 '14 at 00:27
-
spawning a thread does not halt the main thread from running. they should run concurrently – coffeeaddict Aug 27 '14 at 00:27
-
thats not my question coffeeaddict. im asking if a secondary thread gets any NPE can the program continue or does it die ? – j2emanue Aug 27 '14 at 00:30
-
1See http://stackoverflow.com/questions/6546193/how-to-catch-an-exception-from-a-thread – ajb Aug 27 '14 at 00:34
-
from your link ajb it seems the main thread continues and process lives, thank you. – j2emanue Aug 27 '14 at 00:42
1 Answers
1
If a thread exits due to an error, the JVM will continue execution as long as there exists other non-daemon threads. Daemon threads are like normal threads, but do not keep the JVM alive if there only daemon threads still alive. The JVM usually keeps a lot of daemon threads around, including the GC and finalizer threads, to do maintenance and process signals from the OS.

Smith_61
- 2,078
- 12
- 12