본문 바로가기

자바의 정석 기초편16

자바의 정석 기초편 코드 분석 131(예제 13-7) [ ] 자바의 정석 기초편 카테고리 chapter 13 쓰레드 chapter 13-19 데몬 쓰레드(daemon thread) 예제 예제 13-7 [ ] 코드 분석 1. 원본 코드 class Ex13_7 implements Runnable { static boolean autoSave = false; public static void main(String[] args) { Thread t = new Thread(new Ex13_7()); t.setDaemon(true);// 이 부분이 없으면 종료되지 않는다. t.start(); for(int i=1; i 2023. 9. 25.
자바의 정석 기초편 코드 분석 130(예제 13-6) [ ] 자바의 정석 기초편 카테고리 chapter 13 쓰레드 chapter 13-15 쓰레드의 우선순위 예제 예제 13-6 [ ] 코드 분석 1. 원본 코드 class Ex13_6 { public static void main(String args[]) { ThreadEx6_1 th1 = new ThreadEx6_1(); ThreadEx6_2 th1 = new ThreadEx6_2(); th2.setPriority(7); System.out.println("Priority of th1(-) : " + th1.getPriorty()); System.out.println("Priority of th2(|) : " + th2.getPriorty()); th1.start(); th2.start(); } } c.. 2023. 9. 25.
자바의 정석 기초편 코드 분석 129(예제 13-5) [ ] 자바의 정석 기초편 카테고리 chapter 13 쓰레드 chapter 13-5 쓰레드의 I/O블락킹(blocking) 예제2 예제 13-5 [ ] 코드 분석 1. 원본 코드 import javax.swing.JOptionPane; class Ex13_5 { public static void main(String[] args) throws Exception { ThreadEx5_1 th1 = new ThreadEx5_1(); th1.start(); String input = JOptionPane.showInputDialog("아무 값이나 입력하세요."); System.out.println("입력하신 값은 " + input + "입니다."); } } class ThreadEx5_1 extends Th.. 2023. 9. 25.
자바의 정석 기초편 코드 분석 128(예제 13-4) [ ] 자바의 정석 기초편 카테고리 chapter 13 쓰레드 chapter 13-12 쓰레드의 IO/블락킹(blocking) 예제1 예제 13-4 [ ] 코드 분석 1. 원본 코드 import javax.swing.JOptionPane; class Ex13_4 { public static void main(String[] args) throws Exception { String input = JOptionPane.showInputDialog("아무 값이나 입력하세요."); System.out.rpintln("입력하신 값은 " + input + "입니다."); for(int i=10; i > 0; i--) { System.out.println(i); try { Thread.sleep(1000);// 1초.. 2023. 9. 25.