Ejemplo n.º 1
0
 private void InternalRun()
 {
     wrapperThread = this;
     try
     {
         runnable.Run();
     }
     catch (Exception ex)
     {
         JavaSystem.Exception(ex);
     }
     finally
     {
         tgroup.Remove(this);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Destroys this thread group and all of its subgroups. This thread
        /// group must be empty, indicating that all threads that had been in
        /// this thread group have since stopped.
        /// <para>
        /// First, the <code>checkAccess</code> method of this thread group is
        /// called with no arguments; this may result in a security exception.
        ///
        /// </para>
        /// </summary>
        /// <exception cref="IllegalThreadStateException">  if the thread group is not
        ///               empty or if the thread group has already been destroyed. </exception>
        /// <exception cref="SecurityException">  if the current thread cannot modify this
        ///               thread group. </exception>
        /// <seealso cref=        java.lang.ThreadGroup#checkAccess()
        /// @since      JDK1.0 </seealso>
        public void Destroy()
        {
            int ngroupsSnapshot;

            ThreadGroup[] groupsSnapshot;
            lock (this)
            {
                CheckAccess();
                if (Destroyed_Renamed || (Nthreads > 0))
                {
                    throw new IllegalThreadStateException();
                }
                ngroupsSnapshot = Ngroups;
                if (Groups != null)
                {
                    groupsSnapshot = Arrays.CopyOf(Groups, ngroupsSnapshot);
                }
                else
                {
                    groupsSnapshot = null;
                }
                if (Parent_Renamed != null)
                {
                    Destroyed_Renamed = true;
                    Ngroups           = 0;
                    Groups            = null;
                    Nthreads          = 0;
                    Threads           = null;
                }
            }
            for (int i = 0; i < ngroupsSnapshot; i += 1)
            {
                groupsSnapshot[i].Destroy();
            }
            if (Parent_Renamed != null)
            {
                Parent_Renamed.Remove(this);
            }
        }