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.

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:

Screenshot 2020-05-18 at 19.06.25.png

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

Screenshot 2020-05-18 at 19.08.11.png

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.

Screenshot 2020-05-18 at 19.17.04.png

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:

Screenshot 2020-05-18 at 19.24.41.png

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

1 comment

Taranjeet Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2020

Nice article @Alexey Matveev !


Log in or Sign up to comment
AUG Leaders

Atlassian Community Events