Thread

来源:互联网 发布:php 函数缺省参数 编辑:程序博客网 时间:2024/05/30 05:11

Thread

Class Thread Implemented Interface:Runnable.

A thread ia a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution runing concurrently.

now look at this constructor:

public Thread(Runnable target)

Allocates a new Thread object. This constructor has the same effect as Thread(null, target, gname), where gname is a newly generated name. Automatically generated names are of the form "Thread-"+n, where n is an integer.

this is the example:

new Thread(new Runnable() {
                    public void run() {
                        System.out.println(Thread.currentThread().getName()    + " : " + ITL.get());
                        ITL.get().append(", wqf");
                        System.out.println(Thread.currentThread().getName()    + " : " + ITL.get());
                    }
                }).start();

 

 

原创粉丝点击