[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Make Colt-lib: DynamicBin1D Thread safe.



Hello,

I am using the Debian Colt library version 1.2.0 for some heavy
calculations and I see that my system deadlocks randomly. The simplified
test case to reproduce the deadlock is given below. The library is claimed
to be thread safe but deadlocks are found.


import hep.aida.bin.DynamicBin1D;
import cern.colt.function.DoubleDoubleFunction;
import cern.colt.matrix.DoubleFactory1D;
import cern.colt.matrix.DoubleFactory2D;
import cern.colt.matrix.DoubleMatrix1D;
import cern.colt.matrix.DoubleMatrix2D;
import cern.colt.matrix.DoubleMatrix3D;
import cern.jet.random.engine.RandomEngine;
public class OmenTestCase34 {


        public static void main(String args[])
        {
                DynamicBin1D bin = new DynamicBin1D();
                DynamicBin1D bin2 = new DynamicBin1D();
                double[] v1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,  21,
22,23,24,25,26,27,28,29,30,31};
                double[] v2 = {10,11,12,13,14,15,16,17,18,19,  20,
30,31,32,33,34,35,36,37,38,39};
                bin2.addAllOf(new cern.colt.list.DoubleArrayList(v1));
                bin2.addAllOf(new cern.colt.list.DoubleArrayList(v2));
                CovarianceCalculator t1 = new CovarianceCalculator(bin,
bin2);
                t1.start();
                CorrelationCalculator t2 = new CorrelationCalculator(bin,
bin2);
                t2.start();
        }

}
class CovarianceCalculator extends Thread {
        DynamicBin1D l2;
        DynamicBin1D l3;
        public CovarianceCalculator(DynamicBin1D bin, DynamicBin1D bin2) {
                l2 = bin;
                l3 = bin2;
        }

        public void run() {
                System.out.println(l3.covariance(l2));
        }
}

class CorrelationCalculator extends Thread {
        DynamicBin1D l2;
        DynamicBin1D l3;
        public CorrelationCalculator(DynamicBin1D bin, DynamicBin1D bin2) {
                l2 = bin;
                l3 = bin2;
        }

        public void run() {
                System.out.println(l2.correlation(l3));
        }
}

Regards,
Malavika


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


Reply to: