How to kill a jvm thread in Atlassian products

Hello!

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.

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Leave a Reply

%d bloggers like this:

Spelling error report

The following text will be sent to our editors: