Eclipse Debug Multithreading Overview

Source: Internet
Author: User
Tags thread

Used to have a lot of thread development, multithreading development is a little bit of experience, but the beginning of multithreading development, encountered many walls. But in a sense, a good tool always gets the best of it. The tool I use is eclipse, in the development of multithreading, its debug mode is able to directly simulate the multithreaded environment, there are a lot of data online, but most of them are not very full. I hope I can record some of my experience, I hope to help also for multi-threaded development and tangled friends.

First write a simple multithreaded test case:

Package com.wxw.debug;

Publicclass Testmain extends Thread {

@Override

Publicvoid Run () {

System.out.println ("Hello World");

}

Publicstaticvoid Main (string[] args) {

Testmain T1 = new Testmain ();

Testmain t2 = new Testmain ();

T1.start ();

T2.start ();

}

}

This piece of code, the console prints out two lines

Hello World

Next, you'll demonstrate how to use the debug mode for step-by-step execution, and then gradually apply the knowledge extension

Location of breakpoints

Here is a point to note that the location of the breakpoint must be correct, run method or run after the call method, otherwise, the program ran out, debug mode is also only a main thread in the run, well, directly to see the results.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.