Repository: dotnet/runtime
File: src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs (C#)

Code before:
                _ => false,
            };
        }


        /// <summary>
        /// Gets a value that indicates whether the runtime supports multithreading, including
        /// creating threads and using blocking synchronization primitives. This property
        /// returns <see langword="false"/> on platforms or configurations where multithreading
        /// is not supported or is disabled, such as single-threaded browser environments and WASI.
        /// </summary>
        [UnsupportedOSPlatformGuard("browser")]
        [UnsupportedOSPlatformGuard("wasi")]
        [FeatureSwitchDefinition("System.Runtime.CompilerServices.RuntimeFeature.IsMultithreadingSupported")]
        public static bool IsMultithreadingSupported { get; }
#if TARGET_BROWSER
#if FEATURE_SINGLE_THREADED
            = false;
#else
            = true;
#endif
#elif TARGET_WASI
            = false;
#else
            = true;
#endif

#if FEATURE_SINGLE_THREADED
        [DoesNotReturn]
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
            throw new PlatformNotSupportedException();
        }
#else // FEATURE_SINGLE_THREADED
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
#if FEATURE_WASM_MANAGED_THREADS
            System.Threading.Thread.AssureBlockingPossible();
#endif // FEATURE_WASM_MANAGED_THREADS
        }
#endif // FEATURE_SINGLE_THREADED
    }
}


Review comment (performance):
```suggestion
        public static bool IsMultithreadingSupported
#if FEATURE_SINGLE_THREADED
            => false;
#else
            => true;
#endif
```
This does not need to be cached now that it returns a constant.

Also, can the ifdef be simpler? I assume we would have FEATURE_SINGLE_THREADED set for non-MT Wasi builds.

Code after:
                nameof(IsMultithreadingSupported) => IsMultithreadingSupported,
                _ => false,
            };
        }

        /// <summary>
        /// Gets a value that indicates whether the runtime supports multithreading, including
        /// creating threads and using blocking synchronization primitives. This property
        /// returns <see langword="false"/> on platforms or configurations where multithreading
        /// is not supported or is disabled, such as single-threaded browser environments and WASI.
        /// </summary>
        [UnsupportedOSPlatformGuard("browser")]
        [UnsupportedOSPlatformGuard("wasi")]
        [FeatureSwitchDefinition("System.Runtime.CompilerServices.RuntimeFeature.IsMultithreadingSupported")]
        public static bool IsMultithreadingSupported
#if FEATURE_SINGLE_THREADED
            => false;
#else
            => true;
#endif

#if FEATURE_SINGLE_THREADED
        [DoesNotReturn]
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
            throw new PlatformNotSupportedException();
        }
#elif FEATURE_WASM_MANAGED_THREADS
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
            System.Threading.Thread.AssureBlockingPossible();
        }
#else
        [Conditional("unnecessary")]
        internal static void ThrowIfMultithreadingIsNotSupported()
        {
        }
#endif
    }
}