Skip to content

Commit

Permalink
Lightweight -> virtual thread
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanBateman committed Nov 16, 2019
1 parent 7d71fce commit 4516bf3
Show file tree
Hide file tree
Showing 36 changed files with 602 additions and 604 deletions.
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/Object.java
Expand Up @@ -347,7 +347,7 @@ public final void wait(long timeoutMillis) throws InterruptedException {
wait0(timeoutMillis);
} catch (InterruptedException e) {
Thread thread = Thread.currentThread();
if (thread.isLightweight()) {
if (thread.isVirtual()) {
thread.clearInterrupt();
}
throw e;
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/StringCoding.java
Expand Up @@ -73,7 +73,7 @@ private StringCoding() { }
private static final Charset UTF_8 = sun.nio.cs.UTF_8.INSTANCE;

private static <T> T deref(ThreadLocal<SoftReference<T>> tl) {
if (!Thread.currentThread().isLightweight()) {
if (!Thread.currentThread().isVirtual()) {
SoftReference<T> sr = tl.get();
if (sr != null)
return sr.get();
Expand All @@ -82,7 +82,7 @@ private static <T> T deref(ThreadLocal<SoftReference<T>> tl) {
}

private static <T> void set(ThreadLocal<SoftReference<T>> tl, T ob) {
if (!Thread.currentThread().isLightweight())
if (!Thread.currentThread().isVirtual())
tl.set(new SoftReference<>(ob));
}

Expand Down Expand Up @@ -533,7 +533,7 @@ protected StringCoding.Result initialValue() {
}};

private static StringCoding.Result cachedResultObject() {
if (Thread.currentThread().isLightweight()) {
if (Thread.currentThread().isVirtual()) {
return new StringCoding.Result();
} else {
return resultCached.get();
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/System.java
Expand Up @@ -2306,15 +2306,15 @@ public <T> void setCarrierThreadLocal(ThreadLocal<T> local, T value) {
local.setCarrierThreadLocal(value);
}

public void parkLightweightThread() {
public void parkVirtualThread() {
Fiber.park();
}

public void parkLightweightThread(long nanos) {
public void parkVirtualThread(long nanos) {
Fiber.parkNanos(nanos);
}

public void unparkLightweightThread(Thread thread) {
public void unparkVirtualThread(Thread thread) {
((Fiber) thread).unpark();
}
});
Expand Down

0 comments on commit 4516bf3

Please sign in to comment.