Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a VMLangAccess method to create threads #5778

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion jcl/src/java.base/share/classes/com/ibm/oti/vm/VMLangAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


/*******************************************************************************
* Copyright (c) 2012, 2018 IBM Corp. and others
* Copyright (c) 2012, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -155,4 +155,18 @@ public interface VMLangAccess {
public void addPackageToList(Class<?> newClass, ClassLoader loader);
/*[ENDIF] Sidecar19-SE */

/**
* Create a thread that it has runnable as its run object, has threadName as its name, has contextClassLoader as its context ClassLoader,
* has an option to be part of system thread group, has an option to inherit ThreadLocals or not, and has an option to set isDaemon.
*
* @param runnable A java.lang.Runnable whose method <code>run</code> will be executed by the new Thread
* @param threadName Name for the Thread being created
* @param isSystemThreadGroup A boolean indicating whether the thread to be created belongs to the system thread group
* @param inheritThreadLocals A boolean indicating whether to inherit initial values for inheritable thread-local variables
* @param isDaemon Indicates whether or not the Thread being created is a daemon thread
* @param contextClassLoader The context ClassLoader
*
* @return A java.lang.Thread created
*/
public Thread createThread(Runnable runnable, String threadName, boolean isSystemThreadGroup, boolean inheritThreadLocals, boolean isDaemon, ClassLoader contextClassLoader);
}
6 changes: 6 additions & 0 deletions jcl/src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ public Thread(ThreadGroup group, Runnable runnable, String threadName) {
this(group, runnable, threadName, null, true);
}

Thread(Runnable runnable, String threadName, boolean isSystemThreadGroup, boolean inheritThreadLocals, boolean isDaemon, ClassLoader contextClassLoader) {
this(isSystemThreadGroup ? systemThreadGroup : null, runnable, threadName, null, inheritThreadLocals);
this.isDaemon = isDaemon;
this.contextClassLoader = contextClassLoader;
}

private Thread(ThreadGroup group, Runnable runnable, String threadName, AccessControlContext acc, boolean inheritThreadLocals) {
super();
/*[PR 1FEVFSU] Re-arrange method so that common code to this constructor and the private one the VM calls can be put in a separate method */
Expand Down
6 changes: 5 additions & 1 deletion jcl/src/java.base/share/classes/java/lang/VMAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package java.lang;

/*******************************************************************************
* Copyright (c) 2012, 2018 IBM Corp. and others
* Copyright (c) 2012, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -216,4 +216,8 @@ public void addPackageToList(java.lang.Class<?> newClass, ClassLoader loader) {
}
/*[ENDIF] Sidecar19-SE */

@Override
public Thread createThread(Runnable runnable, String threadName, boolean isSystemThreadGroup, boolean inheritThreadLocals, boolean isDaemon, ClassLoader contextClassLoader) {
return new Thread(runnable, threadName, isSystemThreadGroup, inheritThreadLocals, isDaemon, contextClassLoader);
}
}