Exemplo n.º 1
0
        public DisposableObjectCollection <JvmThreadReference> GetAllThreads(JvmNativeEnvironment nativeEnvironment)
        {
            DisposableObjectCollection <JvmThreadReference> result = new DisposableObjectCollection <JvmThreadReference>();

            int    threadsCount;
            IntPtr threads;

            ThrowOnFailure(_rawInterface.GetAllThreads(_env, out threadsCount, out threads));
            try
            {
                unsafe
                {
                    jthread *rawThreads = (jthread *)threads;
                    for (int i = 0; i < threadsCount; i++)
                    {
                        result.Add(new JvmThreadReference(this, nativeEnvironment, rawThreads[i], true));
                    }
                }

                return(result);
            }
            finally
            {
                if (threads != IntPtr.Zero)
                {
                    Deallocate(threads);
                }
            }
        }
Exemplo n.º 2
0
        public DisposableObjectCollection <JvmObjectReference> GetOwnedMonitorInfo(JvmThreadReference thread, JvmNativeEnvironment nativeEnvironment)
        {
            DisposableObjectCollection <JvmObjectReference> result = new DisposableObjectCollection <JvmObjectReference>();

            int    ownedMonitorCount;
            IntPtr ownedMonitors;

            ThrowOnFailure(_rawInterface.GetOwnedMonitorInfo(_env, (jthread)thread, out ownedMonitorCount, out ownedMonitors));
            try
            {
                unsafe
                {
                    jobject *rawMonitors = (jobject *)ownedMonitors;
                    for (int i = 0; i < ownedMonitorCount; i++)
                    {
                        result.Add(new JvmObjectReference(this, nativeEnvironment, rawMonitors[i], true));
                    }
                }

                return(result);
            }
            finally
            {
                if (ownedMonitors != IntPtr.Zero)
                {
                    Deallocate(ownedMonitors);
                }
            }
        }
        public ReadOnlyCollection <JvmThreadReference> GetThreads()
        {
            DisposableObjectCollection <JvmThreadReference>      threads = new DisposableObjectCollection <JvmThreadReference>();
            DisposableObjectCollection <JvmThreadGroupReference> groups  = null;

            Environment.GetThreadGroupChildren(this, threads, groups);
            return(new ReadOnlyCollection <JvmThreadReference>(threads));
        }