1

I've downloaded the early release version from https://jdk.java.net/loom/ and java starts but doing Class.forName("java.lang.Fiber") and Class.forName("java.lang.FiberScope") doesn't work. Is there a flag/jar that needs to be included?

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
zcaudate
  • 13,998
  • 7
  • 64
  • 124
  • First of all -- check that you actually run expected release of java, and not any other installed on your machine. For example, print `System.getProperty("java.version")`. – Pavlus Nov 14 '20 at 16:12
  • Also I didn't find any notion of `java.lang.Fiber` in the repository( https://github.com/openjdk/loom/search?q=fiber ), and usage examples propose thread builders with `.virtual()` method to work with green threads, so maybe you are looking for something that is not there (or may be it was there some time ago and got removed later) – Pavlus Nov 14 '20 at 16:21

2 Answers2

1

The term "fiber" seems to have been changed to "virtual thread".

See 2020-10 interview with Brian Goetz, at 31:00 on YouTube where he mentions the name change.

Look in the early-access Java 16 Javadoc for things like Thread.VirtualThreadTask.

See virtual threads terminology used in JEP draft: Re-implement ThreadGroup, created 2020-09-07.

See code discussed in this 2020-05 article making calls like Thread.startVirtualThread. [May be out-of-date, I do not know.]

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
1

It is a late answer but just to save some time, Since it is still the experimental feature you can use the same using the --enable preview flag on jshell`. Here is how I used it. enter image description here

Manish Mishra
  • 796
  • 6
  • 21