fun runFunc() {
println("함수 실행")
}
fun main() {
println("메인을 실행한다.")
runFunc()
println("메인을 종료한다.")
}
const object = {count:0};
const async_nonblocking_fun = (callback) => {
setTimeout(callback ,1000)
}
const addCount = (object) => {
object['count'] = object['count'] + 1;
console.log(object['count']);
}
const inputTwo = () => {
object['count'] = 2;
console.log(object['count']);
}
addCount(object);
async_nonblocking_fun(inputTwo,object);
addCount(object);
addCount(object);
위의 문제점을 해결하기 위하여 콜백이 호출되는 시점을 우리가 원하는 시점에 제어하는 방법을 사용한다.
위의 한가지 예는 completableFuture이다. 자바스크립트에선 promise와 동일하다고 생각하면 된다.
promise가 강력한 이유
const engineLine = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("engine finish")
resolve("engine")},1000);
})
const frameLine = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("frame finish")
resolve("frame")},1000);
})
const wheelLine = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("wheel finish")
resolve("wheel")},1000);
})
const tireLine = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("tire finish")
resolve("tire")},1000);
})
const finishLine = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("finish")
resolve("tire")},1000);
})
engineLine.then(engineLine)
.then(frameLine)
.then(wheelLine)
.then(tireLine)
.then(finishLine);
멀티 스레드 패턴
리스코프 치환원칙 공부하기
코틀린 컬렉션은 왜 자바의 컬렉션이 있는데도 불구하고 새로 짰을까 ?
근데 왜 이런 위험을 감수하고 왜 만들었을까 ?
메시지 구성요소
request
request line
http 헤더 필드 : 클라이언트와 서버간의 통신에서 요청 응답 모두에 사용되고 있고, 부가적으로 중요한 정보를 전달하는 역할을 담당. 메시지 바디의 크기나 사용하고 있는 언어, 인증 정보 등을 브라우저나 서버에 제공하기 위해 사용되고 있다.
일반 헤더 필드 : 리퀘스트 메시지와 리스폰스 메시지 둘다 사용되는 헤더이다.
Cache-Control : 디렉티브로 불리는 명령을 사용하여 캐싱 동작을 지정함. 여러개의 디렉티브를 지정할 경우 콤마를 사용함. 리퀘스트 및 리스폰스 할 때에 사용가능
캐시가 가능한지 여부를 나타내는 디렉티브
캐시로 보존 가능한 것을 제어하는 디렉티브
캐시 기한이나 검증을 지정하는 디렉티브
Cache-Control 확장
Connection
역할
date
Pragma
Trailer
Transfer-Encoding
Upgrade
via
warning
그외
response
status line
HTTP 헤더 필드