commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: [io] Are FileUtils and IOUtils thread safe?
Date Sun, 30 Sep 2012 14:06:28 GMT
On 29 September 2012 13:39, Martin Gainty <mgainty@hotmail.com> wrote:
>
> Hi Sebb
>
> public class FileUtils {
>
>     /**
>      * Instances should NOT be constructed in standard programming.
>      */
>     public FileUtils() {
>         super();
>     }
>
>     /**
>      * The number of bytes in a kilobyte.
>      */
>     public static final long ONE_KB = 1024;
>
>     /**
>      * The number of bytes in a megabyte.
>      */
>     public static final long ONE_MB = ONE_KB * ONE_KB;
>
>     /**
>      * The number of bytes in a 50 MB.
>      */
>     private static final long FIFTY_MB = ONE_MB * 50;
>
>     /**
>      * The number of bytes in a gigabyte.
>      */
>     public static final long ONE_GB = ONE_KB * ONE_MB;
>
>     /**
>      * An empty array of type <code>File</code>.
>      */
>     public static final File[] EMPTY_FILE_ARRAY = new File[0];
>
>     /**
>      * The UTF-8 character set, used to decode octets in URLs.
>      */
>     private static final Charset UTF8 = Charset.forName("UTF-8");
>
>     //-----------------------------------------------------------------------
>     /**
>      * Returns the path to the system temporary directory.
>      *
>      * @return the path to the system temporary directory.
>      *
>      * @since Commons IO 2.0
>      */
>     public static String getTempDirectoryPath() {
>         return System.getProperty("java.io.tmpdir");
>     }
>
> how is public static immutable?

The qualfiers public and static do not affect immutability.

The fields are final, and the objects themselves are immutable.

Note: final array elements are not immutable, however a zero-length
array has no elements, mutable or otherwise.

> how is public static threadsafe?

Immutable => threadsafe

> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so
bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer
Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und
entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails
koennen wir keine Haftung fuer den Inhalt uebernehmen.
>
>
>
>
>> Date: Sat, 29 Sep 2012 12:49:57 +0100
>> Subject: Re: [io] Are FileUtils and IOUtils thread safe?
>> From: sebbaz@gmail.com
>> To: user@commons.apache.org
>>
>> On 29 September 2012 04:20, Yungwei Chen <yungwei@resolvity.com> wrote:
>> > Hi,
>> >
>> > I would like to know if FileUtils and IOUtils are thread safe. Thanks.
>>
>> The classes themselves are immutable and so are thread safe.
>>
>> However, many of them use JVM classes that may not be thread safe.
>>
>> Also, methods that depend on the state of the file system may not be
>> immune to external influences.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message