java執行緒初上手

2021-08-03 11:06:14 字數 929 閱讀 2901

t.join(1000);  //等待 t 執行緒,等待時間是1000毫秒

總結1:執行緒的建立

public class threadmain 

};thread2.start();

// 二:

// 1.通過建立實現runable的類threadcreate

// 2.實現實現了runnable介面的匿名類

runnable myrunnable = new runnable()

};thread thread3 = new thread(myrunnable);

thread3.start(); }}

//threadcreate類: public class threadcreate extends thread

總結2:執行緒鎖,執行緒sleep以及wait和notify的運用

public class threadwaitnotify  catch (interruptedexception e) }}

};runnable runnable2 = new runnable() catch (exception e) }}

};thread thread1 = new thread(runnable1);

thread thread2 = new thread(runnable2);

thread1.start();

thread2.start();

}}

總結3:多執行緒購票的例子:

public class buyticket implements runnableelse}}

}public static void main(string args)

}

vuejs 初上手專案

學習乙個框架有兩個階段最難,乙個是初期的入門,乙個是後期的原始碼閱讀。雖然vue的官方文件非常棒,在我讀完文件之後還是會有一種感覺,知識點我都懂,然後呢?似乎大體知道該怎麼利用vue全家桶去搭建乙個專案,但具體下筆又有點模糊。vue官方的腳手架並沒有將vue router和vuex包括進去,所以我們...

多執行緒的上手例子

溫習了下python的多執行緒,雖然python中的多執行緒是偽多執行緒,但是還是可以熟悉了解下。coding utf 8 created on 2017年8月17日 author zhouxuan import threading import time def aa print start aa...

java 執行緒 執行緒同步

threadlocal與其它同步機制的比較 threadlocal和其他所有的同步機制都是為了解決多執行緒中的對同一變數的訪問衝突。在普通的同步機制中,是通過對物件加鎖來實現多個執行緒對同一變數的安全訪問的。這時該變數是多個執行緒共享的,使用這種同步機制需要很細緻的分析在什麼時候對變數進行讀寫,什麼...