惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - Ready!

Next.js 开发指南 路由篇 | 动态路由、路由组、平行路由和拦截路由 Next.js 开发指南 路由篇 | App Router Next.js 开发指南 初始篇 | Next.js CLI 设计百万日活用户手游实时排行榜 windows下,chmod 444 .. 的等价操作:操作文件的【安全】属性,保留当前用户的读取和执行权限。 HBase Storage Layout 3,turicreate入门 - 优化回归模型,使得预测更准确 2,turicreate入门 - 一个简单的回归模型 flink 配置 maven打包,带依赖jar python缓存所在目录 docker基础 yum安装 python3 flink 安装 BDAS - Berkeley Data Analytics Stack 分布式存储与传统数据库存储 nginx配置 - 反向代理,转发配置 解决nested exception is java.lang.NoClassDefFoundError: 问题的思路 JetBrains系列破解方法(以idea为主)
模拟死锁
Ready! · 2021-12-18 · via 博客园 - Ready!

模拟死锁

public class MyClass {
    private static Object resourceA = new Object();
    private static Object resourceB = new Object();
    
    public static void main(String args[]) {
      Thread threadA = new Thread( new Runnable() {
          public void run() {
              System.out.println(Thread.currentThread() + " getting A");
              synchronized (resourceA) {
                  System.out.println(Thread.currentThread() + " got A");
                  try {
                      Thread.sleep(1000);
                  } catch(InterruptedException e) {
                      e.printStackTrace();
                  }
                  
                  
                  System.out.println(Thread.currentThread() + " getting B");
                  synchronized (resourceB) {
                      System.out.println(Thread.currentThread() + " got B");
                      try {
                          Thread.sleep(1000);
                      } catch(InterruptedException e) {
                          e.printStackTrace();
                      }
                      
                  }
                  
              }
              
              
          }
      } );
      
      Thread threadB = new Thread( new Runnable() {
          public void run() {
              
              System.out.println(Thread.currentThread() + " getting B");
              synchronized (resourceB) {
                  System.out.println(Thread.currentThread() + " got B");
                  try {
                      Thread.sleep(1000);
                  } catch(InterruptedException e) {
                      e.printStackTrace();
                  }
                  
                  
                  System.out.println(Thread.currentThread() + " getting A");
                  synchronized (resourceA) {
                      System.out.println(Thread.currentThread() + " got A");
                      try {
                          Thread.sleep(1000);
                      } catch(InterruptedException e) {
                          e.printStackTrace();
                      }
                      
                  }
                  
              }
              
              
              
              
          }
      } );
      
      
      threadA.start();
      threadB.start();
    }
}

posted @ 2021-12-18 17:44  Ready!  阅读(75)  评论()    收藏  举报