0

I am new in Java and have got as a task to find out, why after some time running server takes 100% of the CPU. I think I should look, what the threads are doing in this application. As I wanted to stop the Service, the 5605th thread has been started. How do I control which threads are stopped or not, or run for too long?

Thanks.

Gray
  • 115,027
  • 24
  • 293
  • 354
Igor
  • 556
  • 3
  • 19
  • 1
    I think you should be looking into Java profilers such as http://www.yourkit.com/ – Gray Apr 04 '12 at 12:26
  • Take a look at this answer I posted in a previous question: http://stackoverflow.com/a/6868752/425406 This talks about a way to identify the pieces of code which are CPU hogs – Sean Apr 04 '12 at 12:48

2 Answers2

0

The server and client jvms (Java Virtual Machine) are different. The client thinking is basically "you will be one among other dudes trying to use the same resources". The server thinking is "go ahead, you got all the playground for yourself".

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
0

If you are on *nix environment first try to find the process id

  1. Get the process ID. ps -ef | grep "java"
  2. Get the Thread dump. kill -3 processid
  3. Look into the server logs what threads are there and if there are any "Blocking" threads then they are the culprits look at the stack trace and it may give some clues.
srinik
  • 144
  • 1
  • 1
  • 10
  • Try attaching Jconsole to the process and see what actually is happening http://docs.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html – srinik Apr 04 '12 at 15:45