[Java] ReentrantLock 공식문서 파헤쳐보기
·
Dev Lang/JAVA
ReentrantLock공식문서를 보고 학습한 내용을 아카이브해보았습니다.공식문서 링크: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantLock.html#isHeldByCurrentThread-- ReentrantLock (Java Platform SE 8 )Acquires the lock only if it is not held by another thread at the time of invocation. Acquires the lock if it is not held by another thread and returns immediately with the value true, setting the lock..
[Java] 프록시 패턴을 통한 멀티 스레드 환경 조성하기
·
Dev Lang/JAVA
멀티스레드에서의 동시성멀티스레드 환경에서의 컬렉션 프레임워크들은 공유변수에 대한 값을 보장할 수 있을까?수 많은 스레드의 접근에도 유효한 값을 보장하는지에 대한 궁금증을 해결하기 위해 아래의 예시를 준비했습니다. 단순 컬렉션 구현 코드package thread.collection.simple.list;import static util.ThreadUtils.*;import java.util.Arrays;public class BasicList implements SimpleList { private static final int DEFAULT_CAPACITY = 5; private Object[] elementData; private int size = 0; public BasicList() { elem..
[Java] 제네릭 클래스의 이해와 활용
·
Dev Lang/JAVA
학습 키워드Generic Class & InterfaceType ParameterType SafetyCode ReusabilityBounded Type ParameterMultiple Type ParametersRaw TypeType Inference 학습 내용1. 제네릭 클래스의 기본 구조와 필요성Java에서 제네릭이 없던 시절의 코드를 보면 다음과 같은 문제점이 있었다.// 제네릭 이전의 코드class OldBox { private Object item; public void setItem(Object item) { this.item = item; } public Object getItem() { return item; }}// 사용 예시OldBox..
[JAVA] 자바의 기본형과 참조형의 값 공유 특성
·
Dev Lang/JAVA
학습 키워드기본형(Primitive Type)참조형(Reference Type)값 복사(Pass by Value)참조 복사(Pass by Reference)학습 정리1. 기본형(Primitive Type)기본형은 실제 값을 복사하여 전달. 복사본은 원본과 독립적으로 동작하며 서로 영향을 주지 않음.public class PrimitiveExample { public static void main(String[] args) { int x = 10; int y = x; // x의 값 복사 x = 20; // x값 변경 System.out.println("x: " + x); // 출력: 20 System.out.println("y:..
개발자 성현
'Dev Lang/JAVA' 카테고리의 글 목록