MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 9 as of 2026-06-05 17:44:35
  • Java
  • OpenJDK21

Contents

  1. OpenJDK21
    1. Install from Adoptium
    2. Records
    3. Virtual threads

OpenJDK21

Install from Adoptium

  • https://adoptium.net/temurin/releases

  • https://github.com/adoptium/temurin21-binaries/releases/tag/jdk-21.0.7%2B6

   1 cd ~
   2 wget https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.7%2B6/OpenJDK21U-jdk_x64_linux_hotspot_21.0.7_6.tar.gz
   3 tar tvzf OpenJDK21U-jdk_x64_linux_hotspot_21.0.7_6.tar.gz 
   4 tar xvzf OpenJDK21U-jdk_x64_linux_hotspot_21.0.7_6.tar.gz 
   5 nano ~/.bashrc
   6 JAVA_HOME=/home/vitor/jdk-21.0.7+6/
   7 MAVEN_HOME=/home/vitor/apache-maven-3.8.6/
   8 PATH=$JAVA_HOME/bin/:$PATH:$MAVEN_HOME/bin/
   9 # reload bashrc
  10 # . ~/bashrc 
  11 

Records

  • https://openjdk.org/jeps/395

Introduced in release 16.

To model data as data. Easy and concise manner to declare data-carrier classes that by default make their data immutable. Can be described as nominal tuples.

   1   record Point(int x, int y) { }

Virtual threads

  • https://openjdk.org/jeps/444

Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.

   1 try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
   2     IntStream.range(0, 10_000).forEach(i -> {
   3         executor.submit(() -> {
   4             Thread.sleep(Duration.ofSeconds(1));
   5             return i;
   6         });
   7     });
   8 }  // executor.close() is called implicitly, and waits
   9 //---
  10 
  11 void handle(Request request, Response response) {
  12     var url1 = ...
  13     var url2 = ...
  14  
  15     try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
  16         var future1 = executor.submit(() -> fetchURL(url1));
  17         var future2 = executor.submit(() -> fetchURL(url2));
  18         response.send(future1.get() + future2.get());
  19     } catch (ExecutionException | InterruptedException e) {
  20         response.fail(e);
  21     }
  22 }
  23  
  24 String fetchURL(URL url) throws IOException {
  25     try (var in = url.openStream()) {
  26         return new String(in.readAllBytes(), StandardCharsets.UTF_8);
  27     }
  28 }
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01