commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-757) ResizableDoubleArray is not thread-safe yet has some synch. methods
Date Fri, 02 Mar 2012 23:32:54 GMT

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

Sebb commented on MATH-757:
---------------------------

I'm referring to safe publication: because of the Java memory model, changes to variables
are not necessarily made visible (published) to other threads unless both the writer and reader
use the same lock. [Or the variable is volatile]

Furthermore, because the variables are not private, subclasses can change any of the variables
without using synch.

There seems to be no particular reason for the variables to be anything but private; that
would at least prevent external code from changing them arbitrarily.

It also looks to me as though there is no need to make some of the variables mutable, as there
is a ctor which provides them all. Why not just make them final?

This does not seem to be the sort of class that needs runtime config, e.g. via JavaBeans.

                
> ResizableDoubleArray is not thread-safe yet has some synch. methods
> -------------------------------------------------------------------
>
>                 Key: MATH-757
>                 URL: https://issues.apache.org/jira/browse/MATH-757
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Sebb
>
> ResizableDoubleArray has several synchronised methods, but is not thread-safe, because
class variables are not always accessed using the lock.
> Is the class supposed to be thread-safe?
> If so, all accesses (read and write) need to be synch.
> If not, the synch. qualifiers could be dropped.
> In any case, the protected fields need to be made private.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message