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

Method run

day23/code/day23_Thread/src/cn/itcast_08/MovieTicket.java:36–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 // }
35
36 @Override
37 public void run() {
38 while (true) {
39 // ����tickets = 1; t1,t2,t3�ֱ�����������
40 if (tickets > 0) {
41 // ��������ʵ���
42 try {
43 Thread.sleep(100);// t1������,t2������,t3������
44 } catch (InterruptedException e) {
45 e.printStackTrace();
46 }
47
48 // �����ѹ���
49 System.out.println(Thread.currentThread().getName() + "���ڳ��۵�"
50 + (tickets--) + "��Ʊ");
51 // ����1���ڳ��۵�1��Ʊ��tickets=0
52 // ����2���ڳ��۵�0��Ʊ��tickets=-1
53 // ����3���ڳ��۵�-1��Ʊ��tickets=-2
54 }
55 }
56 }
57}

Callers

nothing calls this directly

Calls 2

sleepMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected