< prev index next >

src/java.base/share/classes/java/lang/System.java

Print this page
@@ -52,11 +52,10 @@
  import java.util.Map;
  import java.util.Objects;
  import java.util.Properties;
  import java.util.ResourceBundle;
  import java.util.Set;
- import java.util.concurrent.Executor;
  import java.util.function.Supplier;
  import java.util.concurrent.ConcurrentHashMap;
  import java.util.stream.Stream;
  
  import jdk.internal.javac.Restricted;

@@ -2267,10 +2266,18 @@
  
              public Object scopedValueBindings() {
                  return Thread.scopedValueBindings();
              }
  
+             public long nativeThreadID(Thread thread) {
+                 return thread.nativeThreadID();
+             }
+ 
+             public void setThreadNativeID(long id) {
+                 Thread.currentThread().setNativeThreadID(id);
+             }
+ 
              public Continuation getContinuation(Thread thread) {
                  return thread.getContinuation();
              }
  
              public void setContinuation(Thread thread, Continuation continuation) {

@@ -2301,18 +2308,38 @@
  
              public void unparkVirtualThread(Thread thread) {
                  if (thread instanceof BaseVirtualThread vthread) {
                      vthread.unpark();
                  } else {
-                     throw new WrongThreadException();
+                     throw new IllegalArgumentException();
                  }
              }
  
-             public Executor virtualThreadDefaultScheduler() {
+             public Thread.VirtualThreadScheduler defaultVirtualThreadScheduler() {
                  return VirtualThread.defaultScheduler();
              }
  
+             public boolean isCustomDefaultVirtualThreadScheduler() {
+                 return VirtualThread.isCustomDefaultScheduler();
+             }
+ 
+             public Thread.VirtualThreadScheduler virtualThreadScheduler(Thread thread) {
+                 if (thread instanceof VirtualThread vthread) {
+                     return vthread.scheduler(true);
+                 } else {
+                     throw new IllegalArgumentException();
+                 }
+             }
+ 
+             public <T> T supplyIfUnmounted(Thread thread, Supplier<T> supplyIfAlive, Supplier<T> supplyIfNotAlive) {
+                 if (thread instanceof VirtualThread vthread) {
+                     return vthread.supplyIfUnmounted(supplyIfAlive, supplyIfNotAlive);
+                 } else {
+                     throw new IllegalArgumentException();
+                 }
+             }
+ 
              public StackWalker newStackWalkerInstance(Set<StackWalker.Option> options,
                                                        ContinuationScope contScope,
                                                        Continuation continuation) {
                  return StackWalker.newInstance(options, null, contScope, continuation);
              }
< prev index next >