private void TrySend(int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtInsertIntoCallable(Convert.ToString(i), _engine, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // Assert results
            int totalExpected = numThreads * numRepeats * 2;

            EventBean[] result = _listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, result.Length);
            var results = new LinkedHashMap <long, ICollection <String> >();

            foreach (EventBean theEvent in result)
            {
                var count = theEvent.Get("mycount").AsLong();
                var key   = (String)theEvent.Get("key");

                ICollection <String> entries = results.Get(count);
                if (entries == null)
                {
                    entries = new HashSet <String>();
                    results.Put(count, entries);
                }
                entries.Add(key);
            }

            Assert.AreEqual(numRepeats, results.Count);
            foreach (ICollection <String> value in results.Values)
            {
                Assert.AreEqual(2 * numThreads, value.Count);
                for (int i = 0; i < numThreads; i++)
                {
                    Assert.IsTrue(value.Contains("E1_" + i));
                    Assert.IsTrue(value.Contains("E2_" + i));
                }
            }

            _listener.Reset();
        }
        private void TrySend(EPServiceProvider epService, SupportMTUpdateListener listener, int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtInsertIntoCallable(Convert.ToString(i), epService, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // Assert results
            int totalExpected = numThreads * numRepeats * 2;

            EventBean[] result = listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, result.Length);
            var results = new LinkedHashMap <long, ISet <string> >();

            foreach (EventBean theEvent in result)
            {
                long   count = (long)theEvent.Get("mycount");
                string key   = (string)theEvent.Get("key");

                ISet <string> entries = results.Get(count);
                if (entries == null)
                {
                    entries = new HashSet <string>();
                    results.Put(count, entries);
                }
                entries.Add(key);
            }

            Assert.AreEqual(numRepeats, results.Count);
            foreach (ISet <string> value in results.Values)
            {
                Assert.AreEqual(2 * numThreads, value.Count);
                for (int i = 0; i < numThreads; i++)
                {
                    Assert.IsTrue(value.Contains("E1_" + i));
                    Assert.IsTrue(value.Contains("E2_" + i));
                }
            }

            listener.Reset();
        }