visualvm icon indicating copy to clipboard operation
visualvm copied to clipboard

Tab 'Threads' doesn't refresh thread names and thread renamings.

Open Diarsid opened this issue 5 years ago • 3 comments

Describe the bug In threads list in tab 'Threads' threads that have been renamed do not change their names after they had been initially displayed in list.

To Reproduce Steps to reproduce the behavior:

  1. Write simple application with main(args) method
  2. Start some thread pool with named thread factory setting some %yourPrefix% for thread names and run some tasks to populate pool with threads.
  3. Open VisualVM and go to tab 'threads'. Threads named with the prefix provided in thread factory in step 3 are present in list .
  4. do following thing with your executor: executor.execute(() -> Thread.currentThread().setName(%anotherName%));
  5. Return to VisualVM threads list. Name change %yourPrefix% -> %anotherName% would not be displayed in list. As a matter of fact, thread renaming is done, but VisualVM have not refreshed the list. In order to see renaming result, close this particular JVM tab and open it again - new thread name is visible.

Expected behavior It is expected that thread renaming effect will be displayed in threads list after Thread.setName() invocation.

Desktop (please complete the following information):

  • OS: Windows 10
  • JDK version: 1.8.0_65
  • Version: 1.4.3

Diarsid avatar Oct 08 '19 15:10 Diarsid

For reference, I find thread renaming very helpful for debugging. Every time I get a worker from a thread pool I rename it to indicate what kind of task it is working on. When the task is complete I restore the original name.

cowwoc avatar Aug 09 '22 19:08 cowwoc

+1 our app uses thread pooling but when a worker thread picks up a task the thread name changes to reflect the account / task type. it is useful for debugging

mbigatti avatar Sep 09 '22 12:09 mbigatti

It’s a bug with visualvm and must be fixed. I want to put and updating debugging info to thread names, but visualvm doesn't update it after first load.

JayDi85 avatar Dec 02 '23 09:12 JayDi85