人生第一把死鎖

2021-08-17 10:24:14 字數 963 閱讀 3266

1.背景

程式有兩個入口,乙個是從介面發起,乙個是從mq訊息過來的,同時請求,請求的資源之間相互請求等待,形成死鎖。表現:介面不響應。堆疊顯示有死鎖。 

2.死鎖原因:相互持有同步資源並相互等待。

package testsychronized;

/** * 模仿b級故障重現死鎖現象。

* */

public class testdeadlock

}class thread1 extends thread catch (exception e) }}

class thread2 extends thread catch (exception e) }}

class web catch (interruptedexception e)

system.out.println("get 4 web ending...");

} public static synchronized void settype() catch (interruptedexception e)

system.out.println("set type ending..."); }}

class loadmodel catch (exception e)

system.out.println("get info endining...");

} public static synchronized void loading() catch (exception e)

system.out.println("loading info endining...");

}}

3. synchronizaed少用在方法上,減少鎖的粒度,reentrantlock或者cas或者設計模式解決問題。

第一把火 AliOS Things開啟造血新模式

關注與分享,是對原創最大的鼓勵 看到關於haas開發板的朋友圈,我剛剛從張江x芯獨角獸出來,臉上拂過一絲帶著秋意的風 這haas又是什麼虛頭八腦的東西,從我腦裡狂蹦而出.rtos商業化困局 intel windows的成功,一統了pc時代 aiot時代,嵌入式處理器的容量是pc容量的xx倍,每一顆處...

一把一把撈大資料 釋放無限價值

電商平台對於傳統經濟是個怎樣的存在?是阻礙還是發展,全看你如何選擇。面對新環境還依然按照傳統模式發展必然會受到阻礙,經濟就是要在新的環境下適應新的發展,只故步自封不會有大發展。一把一把撈讓電子商務與大資料技術進一步融合,釋放無限價值。電商平台對於傳統經濟是個怎樣的存在?是阻礙還是發展,全看你如何選擇...

一把鼻涕一把淚 搭建公網ftp伺服器

至於為什麼要搭建公網ftp伺服器,就當我心血來潮吧。ftp開源工具很多,咱用的是filezilla伺服器。後來為了方便搭建web伺服器,就改成了整合工具xampp。客戶端工具也是filezilla client,用瀏覽器也行。首先內網使用者想搭建公網ftp伺服器第乙個要解決的問題是如何得到公網ip。...