• 大小:
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-31
  • 语言: Java
  • 标签: Effective  Java  

资源简介

EffectiveJava 第二版示例源码

资源截图

代码片段和文件信息

// Broken! - How long would you expect this program to run? - Page 259

import java.util.concurrent.*;

public class StopThread {
    private static boolean stopRequested;

    public static void main(String[] args)
            throws InterruptedException {
        Thread backgroundThread = new Thread(new Runnable() {
            public void run() {
                int i = 0;
                while (!stopRequested)
                    i++;
            }
        });
        backgroundThread.start();

        TimeUnit.SECONDS.sleep(1);
        stopRequested = true;
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-10-13 22:40  examples\
     目录           0  2008-05-16 09:32  examples\Chapter10\
     目录           0  2008-05-16 09:32  examples\Chapter10\Item66\
     目录           0  2008-05-16 09:32  examples\Chapter10\Item66\broken StopThread\
     文件         599  2008-05-16 09:32  examples\Chapter10\Item66\broken StopThread\StopThread.java
     目录           0  2017-10-13 22:43  __MACOSX\
     目录           0  2017-10-13 22:43  __MACOSX\examples\
     目录           0  2017-10-13 22:43  __MACOSX\examples\Chapter10\
     目录           0  2017-10-13 22:43  __MACOSX\examples\Chapter10\Item66\
     目录           0  2017-10-13 22:43  __MACOSX\examples\Chapter10\Item66\broken StopThread\
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item66\broken StopThread\._StopThread.java
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item66\._broken StopThread
     目录           0  2008-05-16 09:32  examples\Chapter10\Item66\fixed StopThread 1\
     文件         779  2008-05-16 09:32  examples\Chapter10\Item66\fixed StopThread 1\StopThread.java
     目录           0  2017-10-13 22:43  __MACOSX\examples\Chapter10\Item66\fixed StopThread 1\
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item66\fixed StopThread 1\._StopThread.java
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item66\._fixed StopThread 1
     目录           0  2008-05-16 09:32  examples\Chapter10\Item66\fixed StopThread 2\
     文件         593  2008-05-16 09:32  examples\Chapter10\Item66\fixed StopThread 2\StopThread.java
     目录           0  2017-10-13 22:43  __MACOSX\examples\Chapter10\Item66\fixed StopThread 2\
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item66\fixed StopThread 2\._StopThread.java
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item66\._fixed StopThread 2
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\._Item66
     目录           0  2008-05-16 09:32  examples\Chapter10\Item67\
     文件        1486  2008-05-16 09:32  examples\Chapter10\Item67\ForwardingSet.java
     目录           0  2017-10-13 22:43  __MACOSX\examples\Chapter10\Item67\
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item67\._ForwardingSet.java
     文件        2257  2008-05-16 09:32  examples\Chapter10\Item67\ObservableSet.java
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item67\._ObservableSet.java
     文件         201  2008-05-16 09:32  examples\Chapter10\Item67\SetObserver.java
     文件         212  2008-05-16 09:32  __MACOSX\examples\Chapter10\Item67\._SetObserver.java
............此处省略454个文件信息

评论

共有 条评论