본문 바로가기

Executors 팩토리 클래스 Executors 팩토리 클래스 -- ExecutorService 인터페이스 타입의 ThreadPoolExecutor 객체 반환 -- ScheduledExecutorService 인터페이스 타입의 SheduledThreadPoolExecutor 객체 반환 Executor 인터페이스 -- ExecutorService 인터페이스 -- AbstractThreadPoolExecutor 추상클래스 -- ThreadPoolExecutor 클래스 -- ScheduledThreadPoolExecutor 클래스 -- ScheduledExecutorService 인터페이스 -- ScheduledThreadPoolExecutor 클래스 더보기
wait 메소드 사용시 지켜야 하는 것들 1. 항상 조건 검사 : wait(대기) 할지? 진행 할지?2. wait에서 return 한 후에도 조건 검사 (notifyAll 에 의해 깨어난 경우, 여러 조건큐의 스레드가 깨어남)3. 1번 2번의 이유로 wait 메소드는 반복문 안에서 호출4. 조건 검사는 조건 큐의 lock에 의해 동기화5. wait, notify, notifyAll 메소드를 호출할 때는 조건 큐에 해당하는 락을 확보6. 조건 검사후 작업 진행시 작업이 완료 될때 까지 락을 해제하면 안됨 이 모든 것을 만족하는 코드의 표준적인 형태.void myWait() throws InterreuptedException { synchronized(lock) { while(!myConditionCheck()) { lock.wait(); } //.. 더보기
문자열 속 일부 유니코드 치환 // 문자열 속 일부 유니코드 치환public void replaceUnicodeNotation(String input) {while( true ) {Matcher m = Pattern.compile("\\\\u([\\da-fA-F]{4})").matcher(input);if(!m.find()) break; char ch = (char) Integer.parseInt(m.group(1), 16);String a = String.valueOf( ch );input = m.replaceFirst( Matcher.quoteReplacement(a) );}return input;} 더보기