java - Is it ok if a worker thread that pulls from a BlockingQueue never exits in android? -
i have thread looks this:
public void run() throws interruptedexception { while(true) { string cururl = taskqueue.take(); ... } }
i know can change true
volatile variable, , set false when no longer need it, used throughout application, difficult tell when no longer needed.
i wondering if having infinite loop have visible effect on performance of rest of android vm, if left in blocked state when app not running.
edit 1: code starts thread start if not running.
as taskqueue blocking queue, no. leaving thread running throughout application's life not cause noticeable effect.
if taskqueue wasn't blocking would. application consume near whole core of processing power looping fast can.
a blocking queue cause thread invoking method 'take' halt until there result available return. non-blocking queue return null or throw exception.
Comments
Post a Comment