}
}
Thread t1 = new MyThread();
t1.setPriority(Thread.MIN_PRIORITY);
t1.start();
Thread t2 = new MyThread();
t2.setPriority(Thread.MAX_PRIORITY);
t2.start();
Thread-0: 0
Thread-1: 0
Thread-1: 1
Thread-0: 1
Thread-1: 2
Thread-0: 2
Thread-1: 3
Thread-0: 3
Thread-1: 4
Thread-0: 4
Thread-1: 5
Thread-0: 5
Thread-1: 6
Thread-0: 6
Thread-1: 7
Thread-0: 0
Thread-0: 1
Thread-1: 0
Thread-0: 2
Thread-1: 1
Thread-0: 3
Thread-1: 2
Thread-0: 4
Thread-1: 3
Thread-0: 5
Thread-1: 4
Thread-1: 5
Thread-1: 6
Thread-1: 7
Thread-1: 8
Demon oqimlari (Daemons)
Daemon oqimlari sizga asosiy ijro etaklariga xizmat qilish uchun kerak bo'lgan va ularsiz mavjud bo'lmaydigan fon jarayonlarini tasvirlashga imkon beradi
Guruhda hech qanday to'siqsiz oqimlar qolmasa, virtual mashina tomonidan yo'q qilinadi
void setDaemon (boolean yoqilgan) oqim ko'rinishini sozlaydi. Mavzu boshlanishidan oldin qo'ng'iroq.
boolean isDaemon () Oqim turini qaytaradi: true - demon, false – normal
Demon guruhi oqimlari
Uning oxirgi oqimi to'xtatilganda yoki oqimlarning oxirgi kichik guruhi yo'q qilinganida demon guruhi avtomatik ravishda yo'q qilinadi
void setDaemon (boolean yoq) Guruh ko'rinishini o'rnatadi
boolean isDaemon () guruh turini qaytaradi: true - demon, false – normal
Do'stlaringiz bilan baham: |