Kotlin Coroutines และ Flow
การเขียนโปรแกรมแบบ asynchronous ด้วย Coroutines: launch, async, suspend functions, Dispatchers, Flow, StateFlow, SharedFlow
1Coroutine ใน Kotlin คืออะไร?
Coroutine ใน Kotlin คืออะไร?
คำตอบ
Coroutine คือ thread ที่มีน้ำหนักเบา ช่วยให้เขียนโค้ดแบบ asynchronous ได้อย่างต่อเนื่อง สามารถ suspend ได้โดยไม่บล็อก thread ทำให้งานอื่นทำงานได้ มีประสิทธิภาพมากกว่า thread แบบดั้งเดิม
2ความแตกต่างระหว่าง launch และ async คืออะไร?
ความแตกต่างระหว่าง launch และ async คืออะไร?
คำตอบ
launch เริ่ม coroutine ที่ไม่คืนค่าผลลัพธ์ (คืน Job). async เริ่ม coroutine ที่คืนค่าผลลัพธ์ผ่าน Deferred (await()). ใช้ async เมื่อต้องการผลลัพธ์
3คีย์เวิร์ด suspend ใช้เพื่ออะไร?
คีย์เวิร์ด suspend ใช้เพื่ออะไร?
คำตอบ
suspend ทำเครื่องหมายฟังก์ชันที่สามารถ suspend และดำเนินการต่อในภายหลังโดยไม่บล็อก thread ฟังก์ชันเหล่านี้สามารถเรียกได้จาก suspend functions หรือ coroutines อื่นเท่านั้น ช่วยให้ทำงานแบบ asynchronous ได้
Dispatcher ใน coroutines คืออะไร?
ควรใช้ Dispatchers.IO เมื่อไหร่?
+17 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Android อื่นๆ
พื้นฐาน Android
UI และทรัพยากร Android
Lifecycle ของ Android
การนำทาง Android
การจัดการข้อมูล Android
Networking Android
การทดสอบ Android
Android Gradle
พื้นฐานภาษา Kotlin สำหรับ Android
Room Database
การทำงานเบื้องหลัง
Jetpack Compose
สิทธิ์และฟีเจอร์ของอุปกรณ์
Firebase สำหรับ Android
Android MVVM Architecture
เครือข่าย Android ขั้นสูง
Collections และ Operators ใน Kotlin
การฉีด Dependency ใน Android
Android MVI Architecture
Android Clean Architecture
Android Compose ขั้นสูง
Android Performance and Monitoring
Android Security and Privacy
Android CI/CD and Release
Android UX and Form Factors
Android Testing Advanced
เชี่ยวชาญ Android สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี