commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] Commented: (MATH-188) Make Complex and Fraction classes immutable and thus thread-safe
Date Mon, 04 Feb 2008 04:23:07 GMT

    [ https://issues.apache.org/jira/browse/MATH-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12565258#action_12565258
] 

Sebb commented on MATH-188:
---------------------------

Thread safety also depends on visibility - final fields are guaranteed to be visible to all
threads on exit from the constructor; non-final fields are not.
[c.f. String which changed to using final fields in Java 1.5]

So it seems to me that it would be worth making Fraction immutable (patch to follow).

As to Complex, sorry I'd not noticed that the fields were protected. So deprecate then privatise/finalise
would be "a good idea".

> Make Complex and Fraction classes immutable and thus thread-safe
> ----------------------------------------------------------------
>
>                 Key: MATH-188
>                 URL: https://issues.apache.org/jira/browse/MATH-188
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Sebb
>
> There are many classes with instance fields that could be made final.
> Two in particular seem like ideal candidates:
> Complex - fields: real, imaginary
> Fraction - fields: numerator, denominator (the private reduce() method also needs to
be inlined)
> As far as I can tell, making the above changes makes the classes immutable and therefore
threadsafe.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message