Giter Site home page Giter Site logo

lock-concurrent's Introduction

lock-concurrent

  • Java Thread에 대해 이해
  • Non-Repeatable Read, Phantom Read 동시성 문제 확인
  • JPA와 Spring Data JPA의 ISOLATION LEVEL을 이용한 동시성 문제 해결

실험 준비

  1. docker demon 실행
  2. docker-compose up -d 로 DB 만들기
  3. 원하는 테스트 실행시키기

비관적락 실험

src/test/java/com/solsol/lock/lock/IsolationLevelTest.java 위 파일의 IsolationTest의 3가지 테스트를 진행

  1. givenSingleThreadAndTransaction_whenUpdated_thenSuccess
    • 싱글 스레드를 이용해서 티켓 수량 1개 감소 시키기.
    • 메인 스레드에서 1개의 티켓만 업데이트하니까 성공
  2. givenMultiThreadAndTransaction_whenUpdated_thenFail
    • 20개의 멀티 스레드를 이용해서 티켓 수량 100개 감소 시키기.
    • 스레드끼리 Transaction이 격리되지 않아 실패
  3. givenMultiThreadAndTransaction_whenUpdated_thenSuccess
    • 20개의 멀티 스레드를 이용해서 티켓 수량 100개 감소 시키기.
    • 스레드끼리 비관적 락을 통해 격리되어 성공

lock-concurrent's People

Contributors

haxr369 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.