コード例 #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);
                }
            }
        }