Skip to content Skip to sidebar Skip to footer

Android - Pause And Continue Thread

In my Activity I create a Thread for multiply objects and 'save' them to a hashmap. Is it possible to pause just a single thread of the hasmap and continue it? public void onCreate

Solution 1:

Use a boolean variable to control the thread exection.

ie.

while(!isThreadRunning){

...your statements
}

Once you are moving out of the screen in OnPause method make the variable false/true based on your usage to stop the thread execution.And you have to take care of the persisting hashmap.

Post a Comment for "Android - Pause And Continue Thread"