Open
Conversation
- 하나의 공유 자원에 대해서 여러개의 스레드가 접근했을 때, 동시성 이슈가 발생하여 데이터 정합성 문제가 발생하도록 하였습니다.
- 동시성 문제를 해결하기 위해 synchronized 키워드를 적용했습니다. - 인스턴스 단위 와 블록 단위 동기화를 통해 상호 배제를 구현하여 데이터 정합성을 보장하였습니다.
- 공유 자원인 productDatabase 의 재고 관리를 위해 AtomicInteger 를 적용하였습니다. - compareAndSet 메서드를 활용해 CAS 알고리즘으로 가시성과 원자성을 통해 데이터의 정합성을 보장하였습니다.
- 공유 자원인 productDatabase 의 재고 관리를 위해 ConcurrentHashMap 으로 선언하였습니다. - compute 메서드에서 사용되는 CAS 알고리즘을 통해서 쓰기 작업에서 데이터 정합성을 보장할 수 있습니다.
- 주문 이력을 관리하기 위해 주문 정보를 담을 수 있는 클래스를 작성하였습니다.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 내용
OrderService1에 동시 주문 요청 메소드 synchronized 키워드를 통해 처리 기능 추가OrderService2에 공유 자원인 product 의 stock 을 AtomicInteger 로 관리OrderService3에 공유 자원인 productDatabase 를 ConcurrentHashMap 으로 관리발생했던 문제와 해결 과정을 남겨 주세요.
이번 주차에서 고민되었던 지점이나, 어려웠던 점을 알려 주세요.
리뷰 포인트
기타 질문