Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement multithreading debugging with Intellij IDEA

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to achieve multithreaded debugging in Intellij IDEA. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Multithreaded debugging

Friends who develop too many threaded applications should know that sometimes, in order to observe the different states of variables between multiple threads, as well as the acquisition of locks, they will think of adding a breakpoint debug in the code.

When the breakpoint stops in IDE, you can switch to another thread and run other code without interacting with each other. Of course, there is a switch, which is turned on by default in Eclipse

But it is not enabled by default in IntelliJ IDEA. That is to say, if you add breakpoints to the code in IDEA, although one thread is broken, the other threads have already been executed.

After setting the thread's suspend to the same as the Eclipse mode here, you can also start debugging multithreaded applications.

Simple settings can be changed from suspend to Thread directly at the breakpoint.

Change the default settings in IDEA: switch to "Thread" Radio Button and click the button "Make Default" that appears.

After a thread is broken, it can continue to run in another thread by switching in the thread window.

Switch here in IntelliJ IDEA

We see that both the mainthread and pool-1-thread-1 are in the RUNNING state, so switching to either thread can continue to run.

At this point, you can write a multithreaded application and store content in non-thread-safe containers such as ArryList, and then observe why they are thread-unsafe and what problems will occur.

This is the end of this article on "how to achieve multithreaded debugging in Intellij IDEA". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report