This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 멀티 스레딩과 Race Condition | |
class Counter { | |
private int count = 0; | |
public void incrementWithoutSync() { | |
count++; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// Design Patterns | |
/** | |
* 옵저버 패턴 (Observer Pattern) | |
- 한 객체의 상태 변화가 있을 때 이에 의존하는 객체들에게 자동으로 알림이 전달되는 구조 | |
- 행동 패턴 | |
- 이벤트 기반 구조를 구현할 때 유용하다. | |
* 구현 예시 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 파일 Stream 처리 | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.NoSuchFileException; | |
import java.nio.file.Path; | |
import java.util.function.Function; | |
import java.util.stream.Stream; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// Custom Logging기만들기 | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import java.lang.reflect.Method; | |
@Retention(RetentionPolicy.RUNTIME) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 선택 과제 2번. 가상 선거 및 당선 시뮬레이션 프로그램 | |
import java.util.Random; | |
import java.util.Scanner; | |
public class mission05 { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 사용자 인증 정보 저장 시스템 | |
class User implements Runnable { | |
private ThreadLocal<String> local = new ThreadLocal<>(); | |
private String userName; | |
public User(String userName) { | |
this.userName = userName; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 비동기 결제템시스템 | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.TimeUnit; | |
public class AsyncPaymentProcessor { | |
public static void main(String[] args) { | |
CompletableFuture<Void> future = CompletableFuture.supplyAsync(() -> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 대량 숫자 리스트의 합계 계산 | |
import java.util.stream.LongStream; | |
public class ParallelStreamSumExample { | |
public static void main(String[] args) { | |
long start = System.currentTimeMillis(); | |
long sumSequential = LongStream.rangeClosed(1, 500_000_000).sum(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 일정 간격의 이메일 알림 | |
import java.time.LocalDateTime; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ScheduledExecutorService; | |
import java.util.concurrent.TimeUnit; | |
public class ScheduledThreadPoolExample { | |
public static void main(String[] args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 문서희 | |
// 생산자-소비자 | |
import java.util.LinkedList; | |
import java.util.Queue; | |
class SharedBuffer { | |
private final Queue<Integer> queue = new LinkedList<>(); | |
public synchronized void produce(int value) { |
NewerOlder