Feeling

    三人行,必有我师焉

   ::  :: 新随笔 :: 联系 ::  :: 管理 ::
  185 随笔 :: 0 文章 :: 392 评论 :: 0 Trackbacks
JDK1.6的File.createTempFile方法有bug,在我的机器上第一次调用该方法需要耗时5秒时间,换了好几个1.6的版本均有该问题。JDK1.4,1.5则无此问题。

不一定所有的机器都有此问题,不过这儿肯定是有问题的,起码在我的机器上有问题。
posted on 2012-01-13 15:51 三人行,必有我师焉 阅读(1616) 评论(2)  编辑  收藏

评论

# re: JDK1.6的File.createTempFile方法有bug 2012-01-13 15:57 小明
stackoverflow有类似的问题:
http://stackoverflow.com/questions/2608763/why-does-first-call-to-java-io-file-createtempfilestring-string-file-take-5-se

有人提到是因为用户属于guest group的原因:
As noted as a comment on one of the answers below, I noticed this time is actually spent in the first invocation of SecureRandom.nextLong(). Also, I found that this behavior only occurs when a user has the "Guest" group associated with them. I can execute this test with a user and have it run in less than 100ms and then re-execute the same test with the same user account after just adding that user to the "Guests" group (without removing any other group associations from the user had in the previous run).

你可以验证一下  回复  更多评论
  

# re: JDK1.6的File.createTempFile方法有bug 2012-01-13 17:13 三人行,必有我师焉
@小明
Thanks.   回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航:
 
GitHub |  开源中国社区 |  maven仓库 |  文件格式转换