본문 바로가기
[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.
[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.
[android] AAC 로 app 의 background, foreground 상태 알기 https://medium.com/@arturogdg/background-and-foreground-events-with-android-architecture-components-233fdd9fa855https://developer.android.com/reference/android/arch/lifecycle/Lifecycle -build.gradle 에 아래것을 추가한다.kapt "android.arch.lifecycle:compiler:1.1.1"implementation "android.arch.lifecycle:extensions:1.1.1” -background, foreground state detection 을 위해 아래 클래스를 생성한다.class ApplicationObserver : .. 2018. 11. 24.
Efficient Android Threading #2 스레드 통신 Efficient Android Threading #2 스레드 통신 이 글은 Efficient Android Threading 의 일부 내용만 발췌한 내용입니다.자세한 내용은 책을 구입해서 보세용. 4.1. 파이프 -파이프는 두 개의 연결된 스레드끼리만 접근할 수 있는 메모리에 할당된 버퍼다.두 개의 스레드 이외의 다른 스레드는 데이터에 접근할 수 없다.따라서 스레드 안전이 보장된다.파이프는 단방향이기 때문에 한 스레드는 쓰기만 하고 다른 하나는 읽기만 한다. 일반적으로 파이프는 두 개의 긴 실행 테스크가 있고 하나의 테스크에서 다른 테스크로 계속해서 데이터를 옮길 때 사용된다. -파이프는 바이너리 데이터와 문자 데이터 중 하나를 전송할 수 있다.PipedOutputStream(생산자)와 PipedInp.. 2018. 3. 18.
[android] VSYNC 가 뭐하는 녀석인지 간단히 이야기하면? [android] VSYNC 가 뭐하는 녀석인지 간단히 이야기하면? https://www.youtube.com/watch?v=1iaHxmfZGGchttps://nayaneshguptetechstuff.wordpress.com/2014/07/01/what-is-vsyc-in-android/ -VSYNC 는 Vertical Synchronization 을 이야기한다. -Android 4.1 에 등장한 것으로 Project Butter ( UI 부드럽게 ) 에 나온 방법이다. -VSYNC 는 kernel 에서 fixed interval 로 계속 event 가 오는 것을 이야기한다.animation 이나 window drawing 등이 VSYNC interval 에 맞춰서 진행된다. -GPU 의 fps 와 De.. 2017. 8. 1.
반응형