java mkdirs非线程安全

  1. mkdirs:使用注意,仅仅有创建了目录才返回true,即,整个目录存在,也返回false

    Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

    Returns:

    true if and only if the directory was created, along with all necessary parent directories; false otherwise

  2. 非线程安全:线程A创建目录/var/parentDir/dirA,线程B创建目录/var/parentDir/dirB,假定parentDir目录不存在,线程A创建成功,由于递归调用,线程B创建parentDir时失败,由于短路操作,DirB不创建了


ref:

http://cache.baiducontent.com/c?m=9d78d513d99b12eb0bfa940f524f813d591597634dc0a16668a7965fe3664c373671e3ca30521413a4c76b6671b83828fd864265470237c6eadccf0a83b4c86e69ca303503019b114c8e4cb8cb31748076cc4de9d845b0fced71c8f28c888e070f9f4e563ac6abda0457099c38b6476abde7844c165d14b0ef34&p=8f769a47ce8a11a05bea923657428e&newp=93759a46d1c501e646bbc7710f7acf231610db2151d4db133f9d8d1e&user=baidu&fm=sc&query=java+mkdirs+%CA%A7%B0%DC+%B6%E0%CF%DF%B3%CC&qid=&p1=2 

转载于:https://my.oschina.net/solarxie/blog/314421

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值