Exemple #1
0
        public void testConcurrentAddWidgets()
        {
            WidgetBuilder widgetBuilder =
                new WidgetBuilder(new Class[] {   });
            //www.it - ebooks.infoGood Comments
            String        text     = "'''bold text'''";
            ParentWidget  parent   = null;
            AtomicBoolean failFlag = new AtomicBoolean();

            failFlag.set(false);
            //This is our best attempt to get a race condition
            //by creating large number of threads.
            for (int i = 0; i < 25000; i++)
            {
                WidgetBuilderThread widgetBuilderThread =
                    new WidgetBuilderThread(widgetBuilder, text, parent, failFlag);
                Thread thread = new Thread(new ThreadStart(assertEquals));
                thread.Start();
            }
            assertEquals(false, failFlag.get());
        }
 public BoldWidget(ParentWidget parent, string text)
 {
     Matcher match = Pattern1.matcher(text);
     match.find();
     addChildWidgets(match.group(1));
 }