[coroutine] runBlocking 에 대해 알아보자 - runBlocking 은 새로운 coroutine 을 수행하면서 현재 thread 를 interrupt 가능한 상태로 block 시킨다. 그리고 이 block 은 coroutine 이 종료될때까지 유지된다. - 이 함수는 coroutine 안에서는 사용되지 않아야 한다. (should not) runBlocking 함수는 main 함수 또는 test 에서, blocking style 이면서, suspending style 로의 넘어가기 위한 bridge 의 역할로 사용되도록 디자인 되었다. - 만약 다른 context 가 지정이 된다면, 지정된 context 에서 coroutine 이 수행되고, runBlocking 을 호출한 thread 는 block 된다. - runBlocking 에서 발생하는 .. 2023. 1. 9. [Kotlin] Coroutine 에 대한 이해 : 기본 용어 및 사용 https://android.jlelse.eu/coroutines-basic-terminologies-and-usage-b4242bd1b2a4 Coroutine 이 뭐냐? -Coroutine 은 suspendable computaion instance 이다.코드 블럭이 life-cycle 을 가지고 생성되고 수행된다는 것이 개념상 thread 와 비슷하지만, 특정 thread 에 bound 되어 있지 않다.한 thread 에서 실행되고, 다른 thread 에서 resume 될 수도 있다.future 와 같이 result 나 exception 으로 종료될 수 있다. -Coroutine 은 lightweight thread 라고 볼 수 있다.여러개의 function 을 async 로 호출할 수 있고, 더 짧.. 2020. 8. 7. 반응형 이전 1 다음