下面的程序为什么编译出错:
NotThreadSafe cannot be resolved to a typepackage net.jcip.examples;import net.jcip.annotations.*;/**
 * UnsafeSequence
 *
 * @author Brian Goetz and Tim Peierls
 */@NotThreadSafe
public class UnsafeSequence {
    private int value;    /**
     * Returns a unique value.
     */
    public int getNext() {
        return value++;
    }
}

解决方案 »

  1.   

    这个提示似乎是说,你的net.jcip.annotations.*; 中没有找到@NotThreadSafe 的定义
      

  2.   

    在类中NotThreadSafe不能得到解决,没定义@NotThreadSafe ????????
      

  3.   

    你去http://www.javaconcurrencyinpractice.com/下载jcip-annotations.jar,然后加到lib里就行了,jcip-examples-src.jar不包含annotations的。
    java concurrent in practice还是不错的
      

  4.   

    注释没有引进来吧,NotThreadSafe注释也许在那个包的深处,不用*而用准确包路径是个好习惯喵~```
      

  5.   

    或者声明一个注释就行了,呵呵。public @interface NotThreadSafe {
    }