We can differentiate Service, Thread, and AsyncTask as per their use.
– Services are similar to Activity but it has no UI. Services are working in Background. i.e. If you want to fetch the weather information, for that you cannot create a blank activity for that, so you can use Service.
– A Thread is a class. It is a unit of execution who run parallel to the Main thread is relevant to flag that you can’t update a UI component from the main Thread. It fulfills the set of codes parallel to the main thread.
– AsyncTask is used for managing those tasks that you cannot make to work on the main thread. For example, an HTTP request is a very complex work that cannot be handled on the main thread, so you handle the HTTP request in the AsyncTask.
Regards,
Nitesh Bavishiya