본문 바로가기
[coroutine] Coroutine Basics ( 코루틴 기초 ) https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/basics.md#coroutine-basics Your first coroutine - fun main(){ GlobalScope.launch{ delay(1000L) println("World!") } println("Hello,") Thread.sleep(2000L) } // Hello, // World! - 기본적으로 코루틴은 light-weight thread 이다. CoroutineScope 라는 context 안에서 "launch" 와 같은 coroutine builder 를 통해 시작된다. 위의 예제에서는 GlobalScope 라는 coroutine 을 사용해서 launch 를 했.. 2020. 3. 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.
[android] Doze 모드와 App standby 모드 + GCM High priority message [android] Doze 모드와 App standby 모드 + GCM High priority message https://developer.android.com/training/monitoring-device-state/doze-standby.html -MOS ( 6.0 ) 부터 등장 Doze 모드 -device 가 unplug 된 상태로 오랜 시간 움직여지지 않으면 screen 이 꺼지고, 이 상태에서 시간이 지나면 Doze(깜빡 잠이 들다, 졸다) 모드에 들어간다. -Doze mode 에서는 device 는 주기적으로 아주 짧은 시간동안 resume 되어 보통의 operation 들을 수행한다.이 resume time 에는 app sync 나 pending operation 을 수행하곤 한다. -.. 2017. 9. 17.
반응형