관리 메뉴

나만을 위한 블로그

[Android] 서비스 vs 쓰레드 본문

Android

[Android] 서비스 vs 쓰레드

참깨빵위에참깨빵 2021. 10. 14. 01:08
728x90
반응형

https://stackoverflow.com/questions/9147195/difference-between-service-and-thread-in-android

 

Difference between Service and Thread in Android?

all I need to know is that when I can do some operation using an independent thread, why do I need Service. What is that, a Service can do but a Thread can't? I did go to through many of the posts ...

stackoverflow.com

서비스 : 안드로이드 OS의 메모리 부족으로 파괴될 경우 onStartCommand()에서 START_TRICKY 또는 START_REDELIVER_INTENT를 확인해 서비스를 재시작하는지 확인한다. 안드로이드 컴포넌트라서 메모리 부족으로 앱을 종료하는 동안 고려해야 할 우선순위 수준이 있다.

쓰레드 : 안드로이드 OS에 의해 메모리 부족으로 파괴될 경우 재시작이 보장되지 않는다. 안드로이드의 구성요소가 아니라서 안드로이드는 메모리 부족으로 앱을 종료하는 동안 쓰레드의 우선순위를 고려하지 않는다

 

https://www.quora.com/What-is-the-difference-between-services-and-thread-in-Android

 

What is the difference between services and thread in Android?

Answer (1 of 3): In short, the main difference between Service and Thread is that, Service runs on Main(UI) thread and Thread runes on its own thread. If we are using Service for long tasks, then it may cause block Main UI Thread. Learn free video tutorial

www.quora.com

서비스와 쓰레드의 주요 차이점은 서비스는 메인 쓰레드에서 실행되고 쓰레드는 자체 쓰레드에서 실행된다는 것이다. 긴 작업에 서비스를 사용하는 경우 메인 쓰레드가 차단될 수 있다

 

https://qna.vbagetech.com/question/267/Difference-between-thread-and-service

 

Difference between thread and service - QnA

What is the difference between a Thread and services? As both doing the same thing in different way.

 

qna.vbagetech.com

쓰레드 서비스
백그라운드 프로세스를 수행할 수 있는 OS 수준의 기능 대부분 UI 없이 백그라운드에서 오래 실행되는 작업
자체 쓰레드에서 실행됨 메인 쓰레드에서 실행됨
쓰레드는 경량 프로세스고 안드로이드 컴포넌트가 아니다.
UI 쓰레드를 업데이트할 수 없고 이를 위한 핸들러가 필요함
서비스는 안드로이드 컴포넌트고, 액티비티지만 인터페이스가 없다
액티비티 생명주기에서 실행되며 액티비티가 파괴되면 종료 / 중지된다 서비스는 백그라운드에서 실행되며 액티비티 생명주기와 독립적인 자체 생명주기를 갖는다
따라서 액티비티가 파괴될 때 서비스가 명시적으로 중지되지 않는 한 서비스는 계속 실행된다

 

 

반응형
Comments