Android/java beginner syntax question
<p>so I was watching a tutorial and I am trying to understand this syntax</p>

<pre><code>  Thread thread = new Thread()
    {     
  //if i declare variables here i get errors
            public void run()
            {
            // ....define variables in function
           }
    }
</code></pre>

<p>How does this code work? I think when the thread object is created, it defines adds or "appends" a function to its "list" of functions? So thread.run() or thread.start() can be called later. I'm not sure I'm guessing..can someone enlighten me. From the tutorial I watched in the run function he did this</p>

<pre><code>//the same run that is in the Thread class
public void run()
{
  int timer = 0 ;
  while(timer &lt; 5000)
  {
     sleep(100) ; 
     timer+=100;
  }
}
</code></pre>

<p>What does sleep do? I've googled it but couldn't find anything good. Does it basically stop the current application for 100 ms before it continues with the loop? which means sleep is called 50 times? I'm terrible at maths lol..but if that is so, is the code above equivalent to </p>

<pre><code>public void run()
{
  int timer = 0 ;
  while(timer &lt; 50)
  {
     sleep(100) ; 
     timer++;
  }
}
</code></pre>

<p>However I know the simplest method would just be to say sleep(5000) ;</p>

<p>Clearly, I'm a noob at this..so will appreciate any explanation..the thorough the better thanks. Sorry, no Idea how to use code tags..</p>
