new Thread()는 어떻게 실행될까
·
JAVA
java.lang에 있는 Thread.class를 보면서 Thread가 생성되는 과정을 깊게 공부해보고자 한다! There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started.The other way to create a thread is to declare a class that implements the Runnable interface. That ..
ConcurrentModificationException이란
·
JAVA
1. 개요시험 기간 심심해서 Spring으로 SSE 푸쉬 알람 구현 글을 보던 중CopyOnWriteArrayList를 사용한다는 걸 알았다. 이유는 스레드 관련 동시성 문제였다. 2. ConcurrentModificationException주로 자바에서 List를 사용할 때 ConcurrentModificatoinException을 보기 힘들 것이다.주로 코딩테스트를 볼 때 사용하기 때문이다. 우선 ConcurrentModificatoinException는 List에 대해서 읽기와 쓰기 작업이 동시에 수행될 때, 발생하는 예외이다.어떻게 List에서 읽기와 쓰기가 동시에 일어날 수 있을까? 예시는 다음과 같다.import java.io.*;import java.util.*;public class Mai..
람다식(Lambda expression)
·
JAVA
0. 자바의 정석을 다시 공부하는 이유TAVE 후반기 팀 프로젝트를 하면서 자바 문법에 대해서 부족함을 많이 느꼈다. 1. 예외처리에 대해서 부족함을 느꼈다.2. 람다식과 스트림에 대해서 부족함을 느꼈다. 따라서 자바의 정석 2를 다시 공부하자 1. 람다식(Lambda expression)람다식 = 함수를 간단한 식(expression)으로 표현하는 방법이런 식을int max(int a, int b){ return a > b ? a : b;}아래와 같이 표현하는 걸 람다식이라고 한다.(a,b) -> a > b ? a : b 람다식은 이름이 없는 익명함수이다.(엄밀히 말하면 익명 객체이다.) 함수와 메서드의 차이1. 함수는 일반적 용어, 메서드는 객체지향개념 용어2. 함수는 클래스에 독립적, 메서드는..