How to kill a jvm thread in Atlassian products


In this article I would like to tell you about a way to kill a jvm thread in Atlassian Server products. I was myself introduced to this method by Denis Shestov.

Let s first discuss why would we want to kill a jvm thread?

Suppose, you see that Atlassian Jira takes too much cpu. You can not restart Atlassian Jira because it would make your Atlassian Jira unavailable. In this case you can identify the jvm thread which takes most of the cpu time and kill it.

Another example you are developing a program in SIL and you made a loop in your program which will cause your program be active until this program is killed by the SIL engine. This time depends on the TTL parameter in the SIL engine properties but you would like to kill this program now.

To kill a jvm thread you can use Java Melody app.

I will show you how it works.

First, let’s develop a program in SIL which will cause an infinite loop. Here is the text of such a program:

while (true) {
    string a = "asd";

Run this program in the SIL Manager and it will go to an infinite loop.

Now let’s try to identify this thread by the Java Melody app. Open your browser in http://yourjirapath/monitoring.

Go to the Threads part and push the + sign:

Now try to identify the thread which runs the SIL program. Here is my thread:

You can see that in the thread stacktrace SIL classes are executed.

Now delete the thread. Push on the circle icon in the last column for the found row.

And the thread is killed which means that the script is not running anymore. In the SIL manager you will see that the script threw an exception:

Now the cpu time is not spend on the infinite loop.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: