MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / set

Method set

day24/code/day24_Thread/src/cn/itcast_06/Student.java:8–22  ·  view source on GitHub ↗
(String name, int age)

Source from the content-addressed store, hash-verified

6 private boolean flag = false; // ��ʾ�Ƿ�������
7
8 public synchronized void set(String name, int age) {
9 if (this.flag) {
10 try {
11 this.wait();
12 } catch (InterruptedException e) {
13 e.printStackTrace();
14 }
15 }
16
17 this.name = name;
18 this.age = age;
19
20 this.flag = true;
21 this.notify();
22 }
23
24 public synchronized void get() {
25 if (!this.flag) {

Callers 5

mainMethod · 0.80
runMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80

Calls

no outgoing calls

Tested by 1

mainMethod · 0.64