protected Thread backgroundThread;
backgroundThread = new Thread(this);
backgroundThread.start();
Can someone explain how it works?
Many thanks!

解决方案 »

  1.   

    and please explain the following code as wellpublic void run()implement Runnable
    Thanks!!!
      

  2.   

    backgroundThread = new Thread(this);
       //construct a thread object
    backgroundThread.start();
      //thread object call method start() to start a thread.
    public void run()
    //The run() is a method of the Runnable interface.
    // construt a thread may implements Runnable interface that need implements the run() method
    //or extends a thread.
      

  3.   

    Some help please!
    protected Thread backgroundThread;public static void start()
    {
    if ( backgroundThread==null ) {
    backgroundThread = new Thread();
    backgroundThread.start();
            }
    }

    public void run()
      {
        System.out.println("good");
    Runnable doLater = new Runnable()
    {
      public void run()
      {
        System.out.println("not good");
      }
    };
         SwingUtilities.invokeLater(doLater);
         backgroundThread=null;
     }public static void main(String[] args) throws IOException
    {
    URL l = new URL("http://www.shef.ac.uk");
    start();
    }Why the programming doesn't go throw the public void run()? Prefer some help in Chinese!
      

  4.   

    The class that implements the Runnable interface is regarded as the same Type
    and meanwhile it would be accepted as the sole constructor parameter to be a target 
    whose run method will then be called after the start method is invoked
      

  5.   

    something seems wrong in your run method
    try to remove the Runnable block and test it
      

  6.   

    Thx for all.
    Seems i have solved the problem.
    And could someone give me some sample code of resume, pause a thread?
      

  7.   

    directly call the method on the thread instance
    but deprecated, not recommended,such as stop,suspend alike due to deadlock-prone