본문 바로가기
[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.
Coroutine 과 놀아보기 #1 Coroutine 과 놀아보기 #1 - android studio 에서 coroutine 관련된 것들을 인식 못한다. android 3.2.1 버전으로 업그레이드 하니 해결되었다. 해당 버전 이상으로 환경 세팅을 하고 시작하자! - 이 글은 내가 coroutine 을 학습한 후에 약간 까리한 부분들을, 테스트 코드를 짜서 실험한 결과를 공유하는 글이다. runBlocking? 새로운 coroutine 을 수행하며, 작업이 끝날 때까지 현재 thread 를 block 시킨다. (interrupt 가능하다.) - 다음과 같은 테스트를 해보았다. btn.setOnClickListener{ runBlocking{ startLogPrinting() // mainHandler 에서 50ms 마다 “logPrinti.. 2019. 5. 22.
[Kotlin] Coroutine 소개 (그렇지만 조금 깊을 수도 있음..) [Kotlin] Coroutine 소개 https://www.slideshare.net/elizarov/introduction-to-kotlin-coroutines -Coroutine 개념은 아주 오래된 녀석이다.Simula 67 이란 언어에서 처음으로 소개된 개념이다. detach : suspension statement resume : resume coroutine execution -Coroutine 은 multithreading 이 나오면서 잠시 out 되어있었다.그러나 최근에 async code 가 많이 사용되면서 다시 주목받기 시작했다. -Thread 는 resource 측면에서 high-load 이며,single thread 만 지원하는 언어들도 있으며,mutable state 가 많고, U.. 2018. 11. 27.
[Kotlin] Coroutines tutorial - async code 쉽게 짜기 [Kotlin] Coroutines tutorial - async code 쉽게 짜기 https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md -Kotlin coroutines 는 async code 를 sync code 의 구조를 바꾸지 않고 짤 수 있게 도와준다. Coroutine Basics - modified내용이 바뀌어서 새로 정리하였습니다. -> Coroutine Basics ( 코루틴 기초 ) 예전 기록을 보고 싶으시면 아래 "더보기" 버튼을 눌러주세요!Hello World Coroutine -launch{ delay(1000L) println(“World!”)}println(“Hello,”)Thread.slee.. 2018. 11. 25.
반응형