13 Feb 2021

What is thread in Android?

Hi Bro, How are you?

In this post I shall try to know that what's Thread in Android Programing Language - Java. Beacuse if You are developing an Android Application. At a time, Might be a satution where you have to work with background task which takes long duration. Like download a file form internet connection.

What is Thread?

A bunch of code run behind the user Interface of an Android application.

Name 'thread' also repersent java.util.Thread class. Which is a class that is declared under JAVA package of java.util as utilities. This class actually Impliment Runablee interface.

This Thread class impliment an interface java.util.Runnable.

How many ways android framework provide to create A Thread

1. Runnable Interface.

Runnable is an java interface. It has only on method, that's run() method. This run() method helps to create worker/background thread. Its subclass should have to @override it run() method & provide the code that have to run in background.

public class MyTh Impliment Runnable { 

public void run(){



2. AsynTask Thread

We can create background thread using AsynTask class. It provides better experience to create a thread with it's meaningfull protected and public method.


No comments:

No Comments