what is stuck threads?

What is stuck threads??

How to slove this ??
LVL 20
Sathish David  Kumar NArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

A thread gets stuck when it cannot make progress on some task.

This could be due to a lot of potential reasons.

It could be a deadlock.  Say you have 2 threads A and B.  If A needs something from B and at the same time, B needs something from A - you can get a deadlock.  Neither can advance and both threads get stuck.

It could be stuck in some sort of infinite loop or waiting for some resource that is never available.

If you have no idea where it's getting stuck, you best hope is to attach a profiler, like visualvm:
(comes with the JDK) and use it to view the threads:
and dump a stack trace, which will show you want the stuck thread is trying to do and you may be able to figure it out from there.

It's not likely to be an easy problem to solve - these things are frequently complex.

Good luck - hope that helps,

mccarlIT Business Systems Analyst / Software DeveloperCommented:
It usually means threads that are in deadlock (or possibly livelock). Which is where two threads (or more) can't proceed because one it waiting on some the other thread has locked, but that other thread can't proceed because it is waiting on something that the first thread has locked.

As for how to solve it, well that depends mostly on the code that you are talking about. But in general, a good first principle is to ALWAYS lock resources in the same order.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey Dake Senior Director of TechnologyCommented:
A technique I have seen as well is to find your Java process and do a "kill -quit" on the process. You will then get a thread dump that you could look into in your logs and try to figure out what the threads are doing  and why they might be stuck.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.