简体   繁体   English

匿名对象的生存期在Java中作为线程运行

[英]Lifetime of anonymous object run as thread in Java

Within a method I have the following, 在一种方法中,我有以下几点,

Runnable r = new Runnable() {
                    public void run() {
                       ...
                       ...
                     }                       
                };              
                new Thread(r).start();

What is the lifetime of this anonymous object and thread ? 这个匿名对象和线程的生存期是多少?

What is the lifetime of this anonymous object and thread ? 这个匿名对象和线程的生存期是多少?

1) Thread keeps running until you stop it. 1)线程一直运行,直到您停止它为止。

2) Object scope( r ) is with in the method. 2)方法中包含对象scope( r )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM