부트캠프 기록/Section1

[Java] 심화(Effective)

bbangduck 2022. 9. 18. 16:54

스레드(Thread)

  • 정의
    • 프로세스: 운영체제로부터 자원을 할당받은 작원의 단위
    • 스레드: 프로세스가 할당받은 자원을 이용하는 실행 흐름의 단위

 

  • 메인 스레드와 작업 스레드
  • 스레드를 생성하는 방법
    •  Runnable 인터페이스 구현한 객체에 run() 구현
    •  Thread 클래스 상속 받은 하위 클래스에서 run() 구현

 

  • 스레드 메서드
    • 이름 조회: 스레드참조값.getName()
    • 이름 설정: 스레드참조값.setName()
    • 스레드 인스턴스의 주소값: Thread.currentThread().getName()

 

  • 스레드 동기화 
    • 필요성: 여러 스레드 동일한 데이터를 공유하면 데이터를 덮어쓰는 문제 발생 가능
    • 임계 영역과 락, 키워드 syncronized

 

  • 스레드 상태와 상태 제어 메서드
    • 생성, 실행 대기, 실행, 일시 정지, 소멸 
     

 

자바 가상 머신 (Java Virtual Machine)

  • JVM 정의
    • 자바 코드를 어느 운영 체제에서나 동작할 수 있도록 도와주는 별도의 프로그램

 

  • JVM 구조

  • Garbage Collection
    • 더이상 사용하지 않는 객체를 삭제하여 메모리 확보
    • 동작 방식
      • Minor GC, Major GC
      • 1. Stop The World 
      • 2. Mark and Sweep

 

 

 

출처

1) https://www.geeksforgeeks.org/java-lang-thread-class-java/

 

Java.lang.Thread Class in Java - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

2) https://www.topperskills.com/tutorials/java/java-jvm-internal-architecture-structure.html

 

Internal Structure | Architecture of JVM Java Virtual Machine

The Java Virtual Machine (JVM) is a virtual or abstract machine developed to execute the java programs. A Java Virtual Machine is an implementation of the Java Virtual Machine Specification which executes the Java program (byte code).

www.topperskills.com

 

3)https://jonny-cho.github.io/java/2021/06/01/garbage-collection/

 

가비지 컬렉션(GC)의 원리와 종류 · 개발의숲

가비지 컬렉션(GC)의 원리와 종류 01 Jun 2021 | garbage collection gc 1. 가비지 컬렉션? JVM의 Heap 영역에서 사용하지 않는 객체를 삭제하는 프로세스 (참고) JVM의 메모리 구조 메소드 영역 클래스 멤버 변

jonny-cho.github.io