Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Formating fix and use predefined macros

Signed-off-by: Jack Lu <[email protected]>
  • Loading branch information
fengxue-IS committed Jan 31, 2025
1 parent aa845d1 commit d09ab6f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
49 changes: 25 additions & 24 deletions jcl/src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ private static final class TidLock {
*/
private volatile boolean deadInterrupt;
/*[ENDIF] JAVA_SPEC_VERSION >= 14 */
private volatile boolean started; // If !isAlive(), tells if Thread died already or hasn't even started
private String name; // The Thread's name
private int priority = NORM_PRIORITY; // The Thread's current priority
private volatile boolean started; // If !isAlive(), tells if Thread died already or hasn't even started
private String name; // The Thread's name
private int priority = NORM_PRIORITY; // The Thread's current priority
private boolean isDaemon; // Tells if the Thread is a daemon thread or not.
private volatile int threadStatus; // The Thread's state.

ThreadGroup group; // A Thread belongs to exactly one ThreadGroup
ThreadGroup group; // A Thread belongs to exactly one ThreadGroup
private Runnable runnable; // Target (optional) runnable object
private boolean stopCalled = false; // Used by the VM
private boolean stopCalled = false; // Used by the VM
/*[PR 1FENTZW]*/
private ClassLoader contextClassLoader; // Used to find classes and resources in this Thread
ThreadLocal.ThreadLocalMap threadLocals;
Expand Down Expand Up @@ -1492,32 +1492,33 @@ public static enum State {
/**
* Returns the translation from a J9VMThread state to a Thread::State.
*
* @param status thread status value set by VM.
* @return this thread's state.
*
* @see State
*/
private State translateJ9VMThreadStateToThreadState(int status) {
switch (status) {
case 1: // J9VMTHREAD_STATE_RUNNING
return State.RUNNABLE;
case 2: // J9VMTHREAD_STATE_BLOCKED
return State.BLOCKED;
case 4: // J9VMTHREAD_STATE_WAITING
case 0x80: // J9VMTHREAD_STATE_PARKED
return State.WAITING;
case 8: // J9VMTHREAD_STATE_SLEEPING
case 64: // J9VMTHREAD_STATE_WAITING_TIMED
case 0x100: // J9VMTHREAD_STATE_PARKED_TIMED
return State.TIMED_WAITING;
case 32: // J9VMTHREAD_STATE_DEAD
return State.TERMINATED;
default:
synchronized (lock) {
if (threadRef == NO_REF) {
return State.TERMINATED;
}
return State.values()[getStateImpl(threadRef)];
case 1: // J9VMTHREAD_STATE_RUNNING
return State.RUNNABLE;
case 2: // J9VMTHREAD_STATE_BLOCKED
return State.BLOCKED;
case 4: // J9VMTHREAD_STATE_WAITING
case 0x80: // J9VMTHREAD_STATE_PARKED
return State.WAITING;
case 8: // J9VMTHREAD_STATE_SLEEPING
case 64: // J9VMTHREAD_STATE_WAITING_TIMED
case 0x100: // J9VMTHREAD_STATE_PARKED_TIMED
return State.TIMED_WAITING;
case 32: // J9VMTHREAD_STATE_DEAD
return State.TERMINATED;
default:
synchronized (lock) {
if (threadRef == NO_REF) {
return State.TERMINATED;
}
return State.values()[getStateImpl(threadRef)];
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/threadhelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ monitorWaitImpl(J9VMThread *vmThread, j9object_t object, I_64 millis, I_32 nanos
J9VMTHREAD_SET_BLOCKINGENTEROBJECT(vmThread, vmThread, object);
object = NULL;
/* Set j.l.Thread status to WAITING. */
U_64 oldState = (0 != (thrstate & J9_PUBLIC_FLAGS_THREAD_TIMED))
U_64 oldState = J9_ARE_ANY_BITS_SET(thrstate, J9_PUBLIC_FLAGS_THREAD_TIMED)
? VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING_TIMED)
: VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING);
internalReleaseVMAccessSetStatus(vmThread, thrstate);
Expand Down
2 changes: 1 addition & 1 deletion runtime/vm/threadpark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ threadParkImpl(J9VMThread *vmThread, BOOLEAN timeoutIsEpochRelative, I_64 timeou
J9VMTHREAD_SET_BLOCKINGENTEROBJECT(vmThread, vmThread, J9VMJAVALANGTHREAD_PARKBLOCKER(vmThread, vmThread->threadObject));
TRIGGER_J9HOOK_VM_PARK(vm->hookInterface, vmThread, millis, nanos);
/* Set j.l.Thread status to WAITING. */
U_64 oldState = (0 != (thrstate & J9_PUBLIC_FLAGS_THREAD_TIMED))
U_64 oldState = J9_ARE_ANY_BITS_SET(thrstate, J9_PUBLIC_FLAGS_THREAD_TIMED)
? VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING_TIMED)
: VM_VMHelpers::setThreadState(vmThread, J9VMTHREAD_STATE_WAITING);
internalReleaseVMAccessSetStatus(vmThread, thrstate);
Expand Down

0 comments on commit d09ab6f

Please sign in to comment.