8338383: Implement JEP 491: Synchronize Virtual Threads without Pinning

Co-authored-by: Patricio Chilano Mateo <pchilanomate@openjdk.org>
Co-authored-by: Alan Bateman <alanb@openjdk.org>
Co-authored-by: Andrew Haley <aph@openjdk.org>
Co-authored-by: Fei Yang <fyang@openjdk.org>
Co-authored-by: Coleen Phillimore <coleenp@openjdk.org>
Co-authored-by: Richard Reingruber <rrich@openjdk.org>
Co-authored-by: Martin Doerr <mdoerr@openjdk.org>
Reviewed-by: aboldtch, dholmes, coleenp, fbredberg, dlong, sspitsyn
This commit is contained in:
Patricio Chilano Mateo 2024-11-12 15:23:48 +00:00
parent 8a2a75e56d
commit 78b80150e0
246 changed files with 8295 additions and 2755 deletions

View file

@ -159,16 +159,8 @@ public class ByteArrayOutputStream extends OutputStream {
* @throws NullPointerException if {@code out} is {@code null}.
* @throws IOException if an I/O error occurs.
*/
public void writeTo(OutputStream out) throws IOException {
if (Thread.currentThread().isVirtual()) {
byte[] bytes;
synchronized (this) {
bytes = Arrays.copyOf(buf, count);
}
out.write(bytes);
} else synchronized (this) {
out.write(buf, 0, count);
}
public synchronized void writeTo(OutputStream out) throws IOException {
out.write(buf, 0, count);
}
/**