A lightweight thread is a Thread

Remi Forax forax at univ-mlv.fr
Wed Oct 23 09:38:16 UTC 2019


----- Mail original -----
> De: "Andrew Haley" <aph at redhat.com>
> À: "David Lloyd" <david.lloyd at redhat.com>, "Alan Bateman" <Alan.Bateman at oracle.com>
> Cc: "loom-dev" <loom-dev at openjdk.java.net>
> Envoyé: Mercredi 23 Octobre 2019 10:59:48
> Objet: Re: A lightweight thread is a Thread

> On 10/22/19 5:27 PM, David Lloyd wrote:
>> One would still have to allow subclassing of threads though IMO, even
>> in the lightweight case.  This is enormously useful
> 
> What is it about subclassing Thread that is enormously useful? I can't
> immediately think of any case where a scoped local couldn't achieve the
> same thing. Instead of
> 
>   (MyFoo)Thread.current();
> 
> you'd have
> 
>   CurrentFoo.get();
> 
> ... which would work in lightweight and heavyweight Threads. Is there
> something that definitely wouldn't work with this mechanism ?

all codes that already exist :)

being able to just do a super(..., /*lightweight*/ true) to use a lightweight thread instead of an heavyweight one without having to rewrite all the client code of that subclass of Thread that already exist.

> 
> --
> Andrew Haley  (he/him)
> Java Platform Lead Engineer
> Red Hat UK Ltd. <https://www.redhat.com>
> https://keybase.io/andrewhaley
> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

Rémi


More information about the loom-dev mailing list