小编noe*_*ego的帖子

使用ReferenceQueue和WeakReference

我想在其他线程不再引用时正确关闭Closeable对象.

我写了一些小测试,但是在对象入队后get方法返回null,即poll方法返回没有指示对象的正确Object.

  public static void main(String[] args)
  {
   ReferenceQueue<Closeable> reaped = new ReferenceQueue<Closeable>();
   Closeable s = <SOME CLOSEABLE IMPL>;
   WeakReference<Closeable> ws = new WeakReference<Closeable>(s, reaped);
   s = null;

   System.gc();
   Closeable ro = (Closeable)reaped.poll().get();
   ro.close();
  }
Run Code Online (Sandbox Code Playgroud)

提前致谢.任何帮助将不胜感激.

java

10
推荐指数
1
解决办法
7756
查看次数

IntelliJ的代码编辑器中的多种字体

可以在IntelliJ的代码编辑器中使用多种字体吗?

我最近迷上了菲拉代码的字体,并想用它FlottFlott,如解释在这里,这是一件好事可能与像Atom和崇高的文本编辑器。但是我在IntelliJ上找不到任何东西。

fonts syntax-highlighting intellij-idea

5
推荐指数
0
解决办法
249
查看次数

标签 统计

fonts ×1

intellij-idea ×1

java ×1

syntax-highlighting ×1