[Java笔记]之Concurrency

来源:互联网 发布:笔记本电池检测软件 编辑:程序博客网 时间:2024/06/05 19:06

1.Steps for creating a thread:

  • Place the code for the task into the run method of a class that implements the Runnable interface.
  • Construct a Thread object from the Runnable.  Threat t=new Thread(Runnable object);
  • Start the thread: t.start();

2. In general, the block is simplified ad

  button.addActionListener( f() );

  In the function f(){

      new Runnable(

                run(){

               task....

              interactive with component;

           }

      );

  }