idea中斷點(diǎn)類型之All和Thread的區(qū)別介紹
All模式
- 所有的線程都要在當(dāng)前位置被阻塞,誰先來就先阻塞誰,發(fā)生阻塞時(shí)其他的線程當(dāng)前時(shí)刻執(zhí)行到哪里就在哪里進(jìn)行原地等待。
- 如果此時(shí)按下一步F6,那所有的線程都通過阻塞代碼如果此時(shí)按恢復(fù)程序運(yùn)行F8,那么當(dāng)前線程通過阻塞代碼,等待下一個(gè)線程的到來,也是誰先來阻塞誰,發(fā)生阻塞時(shí)其他的線程當(dāng)前時(shí)刻執(zhí)行到哪里就在哪里進(jìn)行原地等待。
public class ThreadAndAllBreakApplication { public static void main(String[] args) { ThreadTest thread1 = new ThreadTest(); thread1.setName("線程A"); thread1.start(); ThreadTest thread2 = new ThreadTest(); thread2.setName("線程B"); thread2.start(); ThreadTest thread3 = new ThreadTest(); thread3.setName("線程C"); thread3.start(); } } class ThreadTest extends Thread { @Override public void run() { System.out.println(Thread.currentThread().getName() + ": 1"); try { long millis = RandomUtil.randomLong(100, 500); System.out.println(Thread.currentThread().getName() + "睡眠: " + millis); Thread.sleep(millis); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Thread.currentThread().getName() + ": 2"); System.out.println(Thread.currentThread().getName() + ": 3"); System.out.println(Thread.currentThread().getName() + ": 設(shè)置斷點(diǎn)的前一行代碼"); // 當(dāng)前行設(shè)置斷點(diǎn) System.out.println(Thread.currentThread().getName() + ": 4"); System.out.println(Thread.currentThread().getName() + ": end");
線程A: 1
線程C: 1
線程B: 1
線程C睡眠: 283
線程A睡眠: 340
線程B睡眠: 127
線程B: 2
線程B: 3
線程B: 設(shè)置斷點(diǎn)的前一行代碼 // B來到了這里,此時(shí)其他線程A、B在原地等待,即A、B都在睡眠。
線程A: 2 // A之前執(zhí)行到睡眠,現(xiàn)在執(zhí)行2
線程A: 3
線程A: 設(shè)置斷點(diǎn)的前一行代碼 // A來到了這里,此時(shí)其他線程B、C在原地等待
線程C: 2 // c之前執(zhí)行到睡眠,現(xiàn)在執(zhí)行2
線程C: 3
線程A: 4
線程B: 4
線程A: end
線程C: 設(shè)置斷點(diǎn)的前一行代碼 // C來到了這里,如果不放行斷點(diǎn),B一直也不會(huì)輸出end,會(huì)在原地等待(這里證明了當(dāng)某個(gè)線程被All斷點(diǎn)阻塞后,其他線程會(huì)在原地等待)
線程B: end
線程C: 4
線程C: end
Thread模式
所有的線程都會(huì)運(yùn)行到斷點(diǎn)處然后阻塞
- 如果此時(shí)按下一步F6,那當(dāng)前的線程都通過阻塞代碼,其他線程不動(dòng)。
- 如果此時(shí)按恢復(fù)程序運(yùn)行F8,那么當(dāng)前線程通過阻塞代碼,并自動(dòng)切換到下一個(gè)阻塞線程進(jìn)行調(diào)試。
到此這篇關(guān)于idea中斷點(diǎn)類型:All和Thread的區(qū)別的文章就介紹到這了,更多相關(guān)idea 斷點(diǎn)All和Thread內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Mac中IntelliJ IDEA 2019.1注冊過程分享
這篇文章主要介紹了Mac中IntelliJ IDEA 2019.1注冊過程,本文給大家分享到腳本之家平臺(tái)供大家學(xué)習(xí),需要的朋友可以參考下2020-02-02java Date裝成英文String后,無法再轉(zhuǎn)回Date的解決方案
本文介紹了java Date裝成英文String后,無法再轉(zhuǎn)回Date的解決方案。具有一定的參考價(jià)值,下面跟著小編一起來看下吧2017-01-01Java利用ip2region實(shí)現(xiàn)獲取IP地址詳情
ip2region是一個(gè)離線IP地址定位庫和IP定位數(shù)據(jù)管理框架,10微秒級別的查詢效率,提供了眾多主流編程語言的?xdb?數(shù)據(jù)生成和查詢客戶端實(shí)現(xiàn)。本文將利用ip2region實(shí)現(xiàn)獲取IP地址詳情,感興趣的可以了解一下2022-07-07