Skip to content
Open
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
6 changes: 3 additions & 3 deletions conf/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Server port="8055" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
Expand Down Expand Up @@ -65,9 +65,9 @@
AJP Connector: /docs/config/ajp.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
<Connector port="8085" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
redirectPort="8445" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ class TaskThreadFactory implements ThreadFactory {

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement());
Thread t = Thread.ofVirtual().name(namePrefix + threadNumber.getAndIncrement()).unstarted(r);
t.setDaemon(daemon);
t.setPriority(Thread.NORM_PRIORITY);
return t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void start() throws IOException {
if (getChannel().getName() != null) {
channelName = "[" + getChannel().getName() + "]";
}
Thread t = new Thread(this, "NioReceiver" + channelName);
Thread t = Thread.ofVirtual().name("NioReceiver" + channelName).unstarted(this);
t.setDaemon(true);
t.start();
} catch (Exception x) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public TcclThreadFactory(String namePrefix) {

@Override
public Thread newThread(Runnable r) {
final Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement());
final Thread t = Thread.ofVirtual().name(namePrefix + threadNumber.getAndIncrement()).unstarted(r);
t.setContextClassLoader(this.getClass().getClassLoader());
t.setDaemon(true);
return t;
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/juli/FileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public ThreadFactory(final String namePrefix) {

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement());
Thread t = Thread.ofVirtual().name(namePrefix + threadNumber.getAndIncrement()).unstarted(r);
// Threads should not have as context classloader a webapp classloader
t.setContextClassLoader(ThreadFactory.class.getClassLoader());
t.setDaemon(true);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/tomcat/dbcp/pool2/impl/EvictionTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static class EvictorThreadFactory implements ThreadFactory {

@Override
public Thread newThread(final Runnable runnable) {
final Thread thread = new Thread(null, runnable, "commons-pool-evictor");
final Thread thread = Thread.ofVirtual().name("commons-pool-evictor").unstarted(runnable);
thread.setDaemon(true); // POOL-363 - Required for applications using Runtime.addShutdownHook().
thread.setContextClassLoader(EvictorThreadFactory.class.getClassLoader());
return thread;
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/tomcat/util/net/AbstractEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ protected void startAcceptorThread() {
acceptor = new Acceptor<>(this);
String threadName = getName() + "-Acceptor";
acceptor.setThreadName(threadName);
Thread t = new Thread(acceptor, threadName);
Thread t = Thread.ofVirtual().name(threadName).unstarted(acceptor);
t.setPriority(getAcceptorThreadPriority());
t.setDaemon(getDaemon());
t.start();
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/tomcat/util/net/NioEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void startInternal() throws Exception {

// Start poller thread
poller = new Poller();
Thread pollerThread = new Thread(poller, getName() + "-Poller");
Thread pollerThread = Thread.ofVirtual().name(getName() + "-Poller").unstarted(poller);
pollerThread.setPriority(threadPriority);
pollerThread.setDaemon(true);
pollerThread.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static class AsyncIOThreadFactory implements ThreadFactory {

@Override
public Thread newThread(final Runnable r) {
Thread t = new Thread(r);
Thread t = Thread.ofVirtual().unstarted(r);
t.setName("WebSocketClient-AsyncIO-" + count.incrementAndGet());
t.setContextClassLoader(this.getClass().getClassLoader());
t.setDaemon(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ private static class SecureIOThreadFactory implements ThreadFactory {

@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
Thread t = Thread.ofVirtual().unstarted(r);
t.setName("WebSocketClient-SecureIO-" + count.incrementAndGet());
// No need to set the context class loader. The threads will be
// cleaned up when the connection is closed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.apache.tomcat.jdbc.test.driver.Connection;
import org.apache.tomcat.jdbc.test.driver.Driver;
import java.util.concurrent.ThreadFactory;

public class AlternateUsernameTest extends DefaultTestCase {

Expand All @@ -42,6 +43,8 @@ public void testUsernameCompare() throws Exception {
}

private void testUsername(boolean allowUsernameChange) throws Exception {
ThreadFactory threadFactory = Thread.ofVirtual().factory();

long start = System.currentTimeMillis();
int withoutuser =10;
int withuser = withoutuser;
Expand All @@ -58,7 +61,7 @@ private void testUsername(boolean allowUsernameChange) throws Exception {
runners[i] = allowUsernameChange?with:without;
runners[i+withuser] = without;
}
ExecutorService svc = Executors.newFixedThreadPool(withuser+withoutuser);
ExecutorService svc = Executors.newThreadPerTaskExecutor(threadFactory);
List<Future<TestResult>> results = svc.invokeAll(Arrays.asList(runners));
int failures = 0;
int total = 0;
Expand All @@ -74,11 +77,12 @@ private void testUsername(boolean allowUsernameChange) throws Exception {
this.datasource.close();
System.out.println("Nr of connect() calls:"+Driver.connectCount.get());
System.out.println("Nr of disconnect() calls:"+Driver.disconnectCount.get());
System.out.println("Nr of iterations:"+total+" over "+(stop-start)+ " ms.");
System.out.println("Nr of iterations:"+total+" over "+(stop-start)+ " ms.");}

}


@Test

@Test
public void testUsernameCompareAgain() throws Exception {
testUsernameCompare();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
if (useStart) {
ac.start(r);
} else {
Thread t = new Thread(r);
Thread t = Thread.ofVirtual().unstarted(r);
t.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void doTest(int threadCount, int requestCount) throws Exception {
for (int i = 0; i < threadCount; i++) {
runnables[i] =
new TesterRunnable(authenticator, nonce, requestCount);
threads[i] = new Thread(runnables[i]);
threads[i] = Thread.ofVirtual().unstarted(runnables[i]);
}

long start = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
if (useContainerThreadToSetListener) {
asyncCtxt.start(task);
} else {
Thread t = new Thread(task);
Thread t = Thread.ofVirtual().unstarted(task);
t.start();
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/org/apache/catalina/tribes/TesterMulticast.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public class TesterMulticast {
public static void main(String[] args) throws Exception {
// Start Rx Thread
Rx rx = new Rx();
Thread rxThread = new Thread(rx);
Thread rxThread = Thread.ofVirtual().unstarted(rx);
rxThread.setDaemon(true);
rxThread.start();

// Start Tx Thread
Tx tx = new Tx();
Thread txThread = new Thread(tx);
Thread txThread = Thread.ofVirtual().unstarted(tx);
txThread.setDaemon(true);
txThread.start();

Expand Down
2 changes: 1 addition & 1 deletion test/org/apache/catalina/tribes/demos/LoadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static void main(String[] args) throws Exception {
channel.start(startoptions);
Runtime.getRuntime().addShutdownHook(new Shutdown(channel));
while (threads > 1) {
Thread t = new Thread(test);
Thread t = Thread.ofVirtual().unstarted(test);
t.setDaemon(true);
t.start();
threads--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public void run() {

Thread[] threads = new Thread[numThreads];
for(int i=0; i<numThreads; ++i) {
threads[i] = new Thread(job);
threads[i] = Thread.ofVirtual().unstarted(job);
threads[i].setName("Message-Thread-" + i);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void run() {
};
Thread[] threads = new Thread[5];
for (int i=0;i<threads.length;i++) {
threads[i] = new Thread(run);
threads[i] = Thread.ofVirtual().unstarted(run);
}
for (Thread thread : threads) {
thread.start();
Expand Down
2 changes: 1 addition & 1 deletion test/org/apache/coyote/http11/TestHttp11Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void run() {
}
}
};
Thread t = new Thread(send);
Thread t = Thread.ofVirtual().unstarted(send);
t.start();

// Sleep for 1500 ms which should mean the all of request 1 has been
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@ private static String executeOpenSSLCommand(String... args) throws IOException {
InputStreamToText stdout = new InputStreamToText(p.getInputStream());
InputStreamToText stderr = new InputStreamToText(p.getErrorStream());

Thread t1 = new Thread(stdout);
Thread t1 = Thread.ofVirtual().unstarted(stdout);
t1.setName("OpenSSL stdout reader");
t1.start();

Thread t2 = new Thread(stderr);
Thread t2 = Thread.ofVirtual().unstarted(stderr);
t2.setName("OpenSSL stderr reader");
t2.start();

Expand Down
2 changes: 1 addition & 1 deletion test/org/apache/tomcat/websocket/TesterFirehoseServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void onMessage(Session session, String msg) throws IOException {
if (inline) {
writer.doRun();
} else {
Thread t = new Thread(writer);
Thread t = Thread.ofVirtual().unstarted(writer);
t.start();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void onOpen(Session session) {
if (sendOnContainerThread) {
r.run();
} else {
new Thread(r).start();
Thread.startVirtualThread(r);
}
}

Expand Down
2 changes: 1 addition & 1 deletion webapps/examples/WEB-INF/classes/async/Async0.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run() {
}
}
};
Thread t = new Thread(run);
Thread t = Thread.ofVirtual().unstarted(run);
t.start();
}
}
Expand Down
2 changes: 1 addition & 1 deletion webapps/examples/WEB-INF/classes/async/Async1.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void run() {
}
}
};
Thread t = new Thread(run);
Thread t = Thread.ofVirtual().unstarted(run);
t.start();
}

Expand Down
2 changes: 1 addition & 1 deletion webapps/examples/WEB-INF/classes/async/Async2.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void run() {
}
}
};
Thread t = new Thread(run);
Thread t = Thread.ofVirtual().unstarted(run);
t.start();
}

Expand Down
2 changes: 1 addition & 1 deletion webapps/examples/WEB-INF/classes/async/Stockticker.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Stockticker implements Runnable {

public synchronized void start() {
run = true;
ticker = new Thread(this);
ticker = Thread.ofVirtual().unstarted(this);
ticker.setName("Ticker Thread");
ticker.start();
}
Expand Down