Do I need a semaphore for my thread in Android/Java?

Posted by Henrik on Stack Overflow See other posts from Stack Overflow or by Henrik
Published on 2010-06-03T18:48:29Z Indexed on 2010/06/03 18:54 UTC
Read the original article Hit count: 211

Filed under:
|
|
|

Hello all,

When running a thread in Android/Java:

public void run()
{
   while (running)
   {
      if (moreTasksToExec())
      {
         task = getNextTask()
         task.exec();
      }
   }
}

Is it OK to let it run and not using a semaphore to block while no work needs to be executed?

I am only using one thread, so I need no inter-thread synchronization.

© Stack Overflow or respective owner

Related posts about java

Related posts about android