Skip to content

Commit

Permalink
document: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sucese committed Mar 8, 2018
1 parent 6da2578 commit a2ccdfb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -147,14 +147,15 @@ Android系统架构图
- [01Android系统软件设计篇:软件设计原则](https://github.com/guoxiaoxing/android-open-source-project-analysis/blob/master/doc/Android系统软件设计篇/01Android系统软件设计篇:软件设计原则.md)
- [02Android系统软件设计篇:设计模式](https://github.com/guoxiaoxing/android-open-source-project-analysis/blob/master/doc/Android系统软件设计篇/02Android系统软件设计篇:设计模式.md)

有兴趣参与此项目的小伙伴可以扫码入群,本群主要讨论Android Framework、主流开源框架以及Android工程化相关技术,本群不是一个读者群,希望大家每个人都能成为项目的参与者。如果微信群提示满额了可以
加我微信 allenwells 邀请入群。
> 欢迎关注我们的微信公众号,新文章会第一时间发布到掘金博客与微信公众平台,我们也有自己的交流群,下方是QQ交流群,微信群已满,可以加我微信 allenwells 邀请入群。
<img src="https://user-gold-cdn.xitu.io/2018/2/26/161d0b402e9616a6?w=674&h=896&f=jpeg&s=118219" width="300"/>
微信公众平台

后续的技术文章和资料也会做成PDF发送给读者,为了方便群文件管理,这里也建立了一个QQ群。
<img src="https://github.com/BeesAndroid/BeesAndroid/raw/master/art/wechat.png" width="300"/>

<img src="https://user-gold-cdn.xitu.io/2018/2/26/161d0b15a98f790d?w=540&h=740&f=jpeg&s=90598" width="300"/>
QQ交流群

<img src="https://github.com/BeesAndroid/BeesAndroid/raw/master/art/qq.png" width="300"/>

**关于此项目后续的计划**

Expand Down
Binary file modified art/native/memory/memory_manager_structure.graffle
Binary file not shown.
@@ -1,5 +1,8 @@
package com.guoxiaoxing.android.framework.demo.native_framwork.thread;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
* For more information, you can visit https://github.com/guoxiaoxing or contact me by
* guoxiaoxingse@163.com
Expand All @@ -13,10 +16,10 @@ public class ThreadClient {
private Object lock2 = new Object();

public static void main(String[] args) {
new ThreadClient().deadLock();
new ThreadClient().threadMethod();
}

private void deadLock() {
private void deadLock1() {
Thread thread1 = new Thread(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -58,4 +61,43 @@ public void run() {
});
thread2.start();
}

private void deadLock2() {
Lock lock = new ReentrantLock();
lock.lock();
try {
System.out.println("A exception happened");
throw new Throwable("A exception happened");
} catch (Exception e) {
// 不应该在此处释放锁,假如发生无法捕获的异常,会导致锁无法释放,可能会导致死锁
lock.unlock();
} catch (Throwable throwable) {
throwable.printStackTrace();
} finally {
// 应该在此处释放锁
// lock.unlock();
}
}

private void threadMethod(){
Thread thread1 = new Thread(new Runnable() {
@Override
public void run() {
while (true){
System.out.println("I am thread1");
}
}
});
thread1.start();

Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
while (true){
System.out.println("I am thread2");
}
}
});
thread2.start();
}
}

0 comments on commit a2ccdfb

Please sign in to comment.