升级了eclipse4.2后,发现进程容易僵死,启动到一半就没响应了。操作系统: Mac OSX

通过jstack发现有一个进程被block住了:

"main" prio=6 tid=106801000 nid=0x7fff715d2180 waiting for monitor entry [7fff5fbf8000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at java.lang.ClassLoader.findNative(ClassLoader.java:1846)
	- waiting to lock <7cb20b650> (a java.util.Vector)
	at sun.nio.ch.FileDispatcher.pread0(Native Method)
	at sun.nio.ch.FileDispatcher.pread(FileDispatcher.java:31)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:195)
	at sun.nio.ch.IOUtil.read(IOUtil.java:171)
	at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:612)
	at org.apache.lucene.store.NIOFSDirectory$NIOFSIndexInput.readInternal(NIOFSDirectory.java:161)
	at org.apache.lucene.store.BufferedIndexInput.refill(BufferedIndexInput.java:157)
	at org.apache.lucene.store.BufferedIndexInput.readByte(BufferedIndexInput.java:38)
	at org.apache.lucene.store.IndexInput.readInt(IndexInput.java:70)
	at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:611)
	at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:69)
	at org.apache.lucene.index.IndexReader.open(IndexReader.java:476)
	at org.apache.lucene.index.IndexReader.open(IndexReader.java:314)
	at org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.getIndexReader(TaskListIndex.java:758)
	- locked <7c9122468> (a org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex)
	at org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.initialize(TaskListIndex.java:487)
	at org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.<init>(TaskListIndex.java:342)
	at org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.<init>(TaskListIndex.java:318)
	at org.eclipse.mylyn.internal.tasks.index.ui.IndexReference.index(IndexReference.java:58)

怀疑是mylyn做task索引的时候被锁住了。于是找到索引目录 $workspace/.metadata/.mylyn/.taskListIndex ,删除了该目录下的lucene索引,果然启动正常。

然而每次重启的时候都会出现这个问题。又怀疑是eclipse启动或者关闭的时候做任务导致这个问题。于是查看了eclipse设置,发现是Startup and Shutdown选项中的Mylyn Task被勾选了。应该是eclipse关闭的时候没有释放mylyn task索引的锁,导致启动后一直在等待锁释放。

取消Startup设置中的相关选项即可。