< prev index next >

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

Print this page

2248 
2249         @Override
2250         public int read(byte[] b, int off, int len) throws IOException {
2251             boolean attempted = Blocker.begin();
2252             try {
2253                 return super.read(b, off, len);
2254             } finally {
2255                 Blocker.end(attempted);
2256             }
2257         }
2258     }
2259 
2260     /**
2261      * System.out/System.err wrap this output stream.
2262      */
2263     private static class Out extends FileOutputStream {
2264         Out(FileDescriptor fd) {
2265             super(fd);
2266         }
2267 

2268         public void write(int b) throws IOException {
2269             boolean attempted = Blocker.begin();
2270             try {
2271                 super.write(b);
2272             } finally {
2273                 Blocker.end(attempted);
2274             }
2275         }
2276 
2277         @Override
2278         public void write(byte[] b) throws IOException {
2279             boolean attempted = Blocker.begin();
2280             try {
2281                 super.write(b);
2282             } finally {
2283                 Blocker.end(attempted);
2284             }
2285         }
2286 
2287         @Override

2663             public ThreadContainer threadContainer(Thread thread) {
2664                 return thread.threadContainer();
2665             }
2666 
2667             public void start(Thread thread, ThreadContainer container) {
2668                 thread.start(container);
2669             }
2670 
2671             public StackableScope headStackableScope(Thread thread) {
2672                 return thread.headStackableScopes();
2673             }
2674 
2675             public void setHeadStackableScope(StackableScope scope) {
2676                 Thread.setHeadStackableScope(scope);
2677             }
2678 
2679             public Thread currentCarrierThread() {
2680                 return Thread.currentCarrierThread();
2681             }
2682 
2683             public <V> V executeOnCarrierThread(Callable<V> task) throws Exception {
2684                 if (Thread.currentThread() instanceof VirtualThread vthread) {
2685                     return vthread.executeOnCarrierThread(task);
2686                 } else {
2687                     return task.call();
2688                 }
2689             }
2690 
2691             public <T> T getCarrierThreadLocal(CarrierThreadLocal<T> local) {
2692                 return ((ThreadLocal<T>)local).getCarrierThreadLocal();
2693             }
2694 
2695             public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2696                 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2697             }
2698 
2699             public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2700                 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2701             }
2702 
2703             public boolean isCarrierThreadLocalPresent(CarrierThreadLocal<?> local) {
2704                 return ((ThreadLocal<?>)local).isCarrierThreadLocalPresent();
2705             }
2706 
2707             public Object[] scopedValueCache() {
2708                 return Thread.scopedValueCache();
2709             }
2710 

2248 
2249         @Override
2250         public int read(byte[] b, int off, int len) throws IOException {
2251             boolean attempted = Blocker.begin();
2252             try {
2253                 return super.read(b, off, len);
2254             } finally {
2255                 Blocker.end(attempted);
2256             }
2257         }
2258     }
2259 
2260     /**
2261      * System.out/System.err wrap this output stream.
2262      */
2263     private static class Out extends FileOutputStream {
2264         Out(FileDescriptor fd) {
2265             super(fd);
2266         }
2267 
2268         @Override
2269         public void write(int b) throws IOException {
2270             boolean attempted = Blocker.begin();
2271             try {
2272                 super.write(b);
2273             } finally {
2274                 Blocker.end(attempted);
2275             }
2276         }
2277 
2278         @Override
2279         public void write(byte[] b) throws IOException {
2280             boolean attempted = Blocker.begin();
2281             try {
2282                 super.write(b);
2283             } finally {
2284                 Blocker.end(attempted);
2285             }
2286         }
2287 
2288         @Override

2664             public ThreadContainer threadContainer(Thread thread) {
2665                 return thread.threadContainer();
2666             }
2667 
2668             public void start(Thread thread, ThreadContainer container) {
2669                 thread.start(container);
2670             }
2671 
2672             public StackableScope headStackableScope(Thread thread) {
2673                 return thread.headStackableScopes();
2674             }
2675 
2676             public void setHeadStackableScope(StackableScope scope) {
2677                 Thread.setHeadStackableScope(scope);
2678             }
2679 
2680             public Thread currentCarrierThread() {
2681                 return Thread.currentCarrierThread();
2682             }
2683 








2684             public <T> T getCarrierThreadLocal(CarrierThreadLocal<T> local) {
2685                 return ((ThreadLocal<T>)local).getCarrierThreadLocal();
2686             }
2687 
2688             public <T> void setCarrierThreadLocal(CarrierThreadLocal<T> local, T value) {
2689                 ((ThreadLocal<T>)local).setCarrierThreadLocal(value);
2690             }
2691 
2692             public void removeCarrierThreadLocal(CarrierThreadLocal<?> local) {
2693                 ((ThreadLocal<?>)local).removeCarrierThreadLocal();
2694             }
2695 
2696             public boolean isCarrierThreadLocalPresent(CarrierThreadLocal<?> local) {
2697                 return ((ThreadLocal<?>)local).isCarrierThreadLocalPresent();
2698             }
2699 
2700             public Object[] scopedValueCache() {
2701                 return Thread.scopedValueCache();
2702             }
2703 
< prev index next >