提交 e3ebf4a0 编写于 作者: M Mars Liu

fixed dead lock

上级 4abe432a
......@@ -2,6 +2,6 @@
"type": "code_options",
"author": "zxm2015",
"source": "Annotation.md",
"notebook_enable": true,
"notebook_enable": false,
"exercise_id": "0c8cac5c81694e059635025cceaba40c"
}
\ No newline at end of file
......@@ -2,6 +2,6 @@
"type": "code_options",
"author": "zxm2015",
"source": "Apt.md",
"notebook_enable": true,
"notebook_enable": false,
"exercise_id": "3abe982223824612bdf4a78ab47225b7"
}
\ No newline at end of file
......@@ -3,5 +3,5 @@
"author": "zxm2015",
"source": "Abstract.md",
"exercise_id": "c0b3c3a116444a9da55c0e03d4cbc928",
"notebook_enable": true
"notebook_enable": false
}
\ No newline at end of file
......@@ -3,5 +3,5 @@
"author": "zxm2015",
"source": "Thread.md",
"exercise_id": "cb9e91c0bc524d1a85dff099ca525375",
"notebook_enable": true
"notebook_enable": false
}
\ No newline at end of file
......@@ -3,5 +3,5 @@
"author": "zxm2015",
"source": "ThreadStatus.md",
"exercise_id": "91345807aa8842df8546b70f2aa76a57",
"notebook_enable": true
"notebook_enable": false
}
\ No newline at end of file
......@@ -3,5 +3,5 @@
"author": "zxm2015",
"source": "ProductorAndConsumer.md",
"exercise_id": "5297702807ce4117ab0d2f739d6985b8",
"notebook_enable": true
"notebook_enable": false
}
\ No newline at end of file
# 生产者消费者
生产者消费者是软件开发者经常会用到的一种模式,以下代码是一种简单的实现:
```java
class Producter extends Thread {
private BlockingQueue<String> queue;
......@@ -43,7 +44,9 @@ public class ThreadTest {
}
}
```
要输出的结果为
```
b0
b1
......@@ -52,6 +55,7 @@ a0
a1
a2
```
则1处的代码可以是下列选项中的哪一个?
......
......@@ -3,5 +3,5 @@
"author": "zxm2015",
"source": "DeadLock.md",
"exercise_id": "2f421bd88a7b4afd9a38d92e2c57d521",
"notebook_enable": true
"notebook_enable": false
}
\ No newline at end of file
# DeadLock
两个线程分别运行以下代码的eatDrink和drinkEat, 会不会发生死锁:
```java
public class DeadLock {
private final String eat = "吃饭";
......@@ -49,3 +50,15 @@ public class DeadLock {
```
不会
```
### B
```
只有在多核环境下才会死锁
```
### C
```
只有多核环境下才不会死锁
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册