public void testHasherThreadSafety()
        {
            string         hashString  = "threaded hash string - should always hash to the same 32 character value";
            string         hashedValue = StringUtils.getMD5Hash(hashString);
            int            numThreads  = 1024;
            IList <Thread> threads     = new List <Thread>(numThreads);

            HashStringSwallower[] hsses = new HashStringSwallower[numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                hsses[i] = new HashStringSwallower(hashString);
                threads.Add(new Thread(new ThreadStart(hsses[i].go)));
            }

            for (int i = 0; i < numThreads; i++)
            {
                threads[i].Start();
            }

            for (int i = 0; i < numThreads; i++)
            {
                threads[i].Join();
            }

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(String.Equals(hsses[i].Hash, hashedValue));
            }
        }
Exemple #2
0
        public void testHasherThreadSafety()
        {
            string hashString = "threaded hash string - should always hash to the same 32 character value";
            string hashedValue = StringUtils.getMD5Hash(hashString);
            int numThreads = 1024;
            IList<Thread> threads = new List<Thread>(numThreads);
            HashStringSwallower[] hsses = new HashStringSwallower[numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                hsses[i] = new HashStringSwallower(hashString);
                threads.Add(new Thread(new ThreadStart(hsses[i].go)));
            }

            for (int i = 0; i < numThreads; i++)
            {
                threads[i].Start();
            }

            for (int i = 0; i < numThreads; i++)
            {
                threads[i].Join();
            }

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(String.Equals(hsses[i].Hash, hashedValue));
            }
        }