Java – is system. Java guaranteed Nanotime() returns a unique value?

I have a multithreaded Java program that creates hundreds of temporary files in seconds Put the file in / TMP and use system Nanotime() naming

Is the file name guaranteed to be unique?

Solution

No, there is no guarantee that every time you call system Nanotime() will return a unique value

Use file. Instead Createtempfile() or files createTempFile(). They are designed for this purpose only and generate unique file names for you

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>