6

Proposed Java API would enable sharing of immutable data across threads

 1 year ago
source link: https://www.infoworld.com/article/3673293/proposed-java-api-would-enable-sharing-of-immutable-data-across-threads.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Proposed Java API would enable sharing of immutable data across threads

Extent-local variables would provide a way to share data both within a thread and with child threads in Java, making it easier to reason about data flow.

By Paul Krill

Editor at Large,

InfoWorld | Sep 12, 2022 9:00 am PDT

data flow
Dell Technologies

Java could gain a capability for sharing immutable data across threads, based on a plan now under consideration in the OpenJDK realm.

An OpenJDK proposal for extent-local variables, currently an incubating API, would provide a programming model to share data both within a thread and with child threads. Extent-local variables are preferred to thread-local variables, particularly when using large numbers of virtual threads, the proposal states.

[ Also on InfoWorld: 7 reasons Java is still great ]

The proposal lists four goals behind the incubating API:

  • Ease of use, to simplify reasoning about data flow.
  • Comprehensibility, to make the lifetime of shared data visible from the syntactic structure of code.
  • Robustness, to ensure that data shared by a caller can be retrieved only by legitimate callees.
  • Performance, to treat shared data as immutable to allow sharing by a large number of threads and enable runtime optimizations.

The extent local-variables API currently is not slated for any particular version of standard Java. The earliest it could potentially appear would be in Java 20, due in March 2023. Java 19, or Java Development Kit 19, due to arrive on September 20, is closed to new features.

The extent-local variables plan does not involve changing the Java programming language itself. There also is no intent to require migration away from thread-local variables, or to deprecate the existing ThreadLocal API.

Paul Krill is an editor at large at InfoWorld, whose coverage focuses on application development.

Follow

Copyright © 2022 IDG Communications, Inc.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK