Is there a default timeout for threads waiting on a synchronised method in Java? Some threads in my app are not completing as expected. Is there anyway to check whether threads have died as a result of timeouts?
If a method is waiting on a synchronization object it should never die, but it could be waiting for an awfully long time (as in, "forever") if something goes wrong. Perhaps your program is never releasing a lock on a resource?
You can set a timeout on the join() method to make sure you don't wait forever.
I'd have a look at the java.util.concurrent packages to see if there were new features added to help your situation.
I'd also recommend "Java Concurrency In Practice" by Brian Goetz. (I need to re-read it again myself.)
Threads in Java don't just die suddenly. Either they are not progressing (blocked on a lock or infinite loop or similar), or if an exception is thrown and it is not handled, then the thread's execution will stop when the exception propagates to the top level (which should then print the exception's stack trace to System.err).
If your application is deadlocking, one way to find out the reason is to make a thread dump. The JVM can also itself detect simple deadlocks, in which case it will report them in the thread dump.
You can generate a thread dump under Linux by running kill -QUIT <pid>
and under Windows by hitting Ctrl + Break
in the console window. Or even simpler, use VisualVM, StackTrace or a similar tool.
I suggest you use kill -3 to see a thread dump, and then see what the problematic threads are.