@Test public void building_cyclic_thread_group_hierarchies() throws Exception { WorkerThreadGroup wtg1 = new WorkerThreadGroup("g1"); WorkerThreadGroup wtg2 = new WorkerThreadGroup("g2"); WorkerThreadGroup wtg3 = new WorkerThreadGroup("g3"); wtg1.add_subgroup(wtg2); wtg2.add_subgroup(wtg3); boolean fail = false; try { wtg3.add_subgroup(wtg1); fail = true; } catch (AssertionError e) { } if (fail) { fail(); } }
public synchronized void add_subgroup(WorkerThreadGroup wtg) { Ensure.not_null(wtg, "wtg == null"); Ensure.is_true(wtg != this, "wtg == this"); Ensure.is_false(m_subgroups.contains(wtg), "m_subgroups.contains(wtg)"); Ensure.is_false(wtg.all_subgroups().contains(this), "wtg.all_subgroups().contains(this)"); m_subgroups.add(wtg); }
WorkerThreadGroup implements WorkerThreadGroupCI { public synchronized void add_subgroup(WorkerThreadGroup wtg) { Ensure.not_null(wtg, "wtg == null"); Ensure.is_true(wtg != this, "wtg == this"); Ensure.is_false(m_subgroups.contains(wtg), "m_subgroups.contains(wtg)"); Ensure.is_false(wtg.all_subgroups().contains(this), "wtg.all_subgroups().contains(this)"); m_subgroups.add(wtg); } }
WorkerThreadGroup implements WorkerThreadGroupCI { public synchronized void add_subgroup(WorkerThreadGroup wtg) { Ensure.not_null(wtg, "wtg == null"); Ensure.is_true(wtg != this, "wtg == this"); Ensure.is_false(m_subgroups.contains(wtg), "m_subgroups.contains(wtg)"); Ensure.is_false(wtg.all_subgroups().contains(this), "wtg.all_subgroups().contains(this)"); m_subgroups.add(wtg); } WorkerThreadGroup(String name); }
WorkerThreadGroup implements WorkerThreadGroupCI { public synchronized void add_subgroup(WorkerThreadGroup wtg) { Ensure.not_null(wtg, "wtg == null"); Ensure.is_true(wtg != this, "wtg == this"); Ensure.is_false(m_subgroups.contains(wtg), "m_subgroups.contains(wtg)"); Ensure.is_false(wtg.all_subgroups().contains(this), "wtg.all_subgroups().contains(this)"); m_subgroups.add(wtg); } WorkerThreadGroup(String name); @Override synchronized String name(); @Override synchronized String description(); synchronized void description(String d); @Override synchronized Set<WorkerThreadCI> threads(); @Override synchronized void start(); @Override synchronized void stop(); synchronized void add_thread(WorkerThread wt); synchronized void remove_thread(WorkerThread wt); synchronized void add_subgroup(WorkerThreadGroup wtg); synchronized void remove_subgroup(WorkerThreadGroup wtg); @Override synchronized Set<WorkerThreadGroupCI> direct_subgroups(); @Override Set<WorkerThreadGroupCI> all_subgroups(); @Override void start_all(); @Override void stop_all(); }
WorkerThreadGroup implements WorkerThreadGroupCI { public synchronized void add_subgroup(WorkerThreadGroup wtg) { Ensure.not_null(wtg, "wtg == null"); Ensure.is_true(wtg != this, "wtg == this"); Ensure.is_false(m_subgroups.contains(wtg), "m_subgroups.contains(wtg)"); Ensure.is_false(wtg.all_subgroups().contains(this), "wtg.all_subgroups().contains(this)"); m_subgroups.add(wtg); } WorkerThreadGroup(String name); @Override synchronized String name(); @Override synchronized String description(); synchronized void description(String d); @Override synchronized Set<WorkerThreadCI> threads(); @Override synchronized void start(); @Override synchronized void stop(); synchronized void add_thread(WorkerThread wt); synchronized void remove_thread(WorkerThread wt); synchronized void add_subgroup(WorkerThreadGroup wtg); synchronized void remove_subgroup(WorkerThreadGroup wtg); @Override synchronized Set<WorkerThreadGroupCI> direct_subgroups(); @Override Set<WorkerThreadGroupCI> all_subgroups(); @Override void start_all(); @Override void stop_all();  }