Hey John,

Without commenting on whether threads in Java are always tied to native
threads (I don't think this is always strictly true), sounds like there
might be a misunderstanding here. What is special about threads in
particular that make you think `any_code` wouldn't be JIT-able here? Put
another way: code in the thread that creates `t` (e.g. the "main" thread)
could presumably be JIT-ed, so why not the code in `t`?

When you run javac, you end up with classfiles that contain bytecode &
metadata. That bytecode is loaded by the JVM at runtime. A JVM might then
start profiling this code using a bytecode interpreter to identify "hot"
methods. Those might then become candidates for the JIT. I'm not sure that
threads really come into it -- at least not at the level you're talking
about.

This story can get a little more complicated when you're using the server
compiler & tiered compilation (pretty sure this is the default in Oracle
JVM for Java 8, at least on Linux):
https://docs.oracle.com/javase/7/docs/technotes/guides/vm/performance-enhancements-7.html#tieredcompilation
... but even then, threads don't really change the story.

Does this help at all?

Cheers,
Tom

On Sun, Nov 12, 2017 at 3:17 PM, John Hening <[email protected]> wrote:

> Hello,
>
>
> I would like to ask for threads in Java. As we know, JVM uses system threads 
> (native threads). So, for example it uses Linux threads. In simplification a 
> thread is a stack + piece of code to execute.
>
>
> Let's consider:
>
>
> Thread t = new Thread(() -> {`any_code`});
> t.start();
> t.join();
>
>
>
> `any_code` will be compile to bytecode. So, how the thread is executed? We 
> can assume that that code wouldn't be jited. I cannot understand what is a 
> content of that thread? After all, bytecode must be interpreted
>
> by JVM. So, does the thread execute a JVM that interprets a bytecode 
> `any_code`?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "mechanical-sympathy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Tom Lee */ http://tomlee.co / @tglee <http://twitter.com/tglee>

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to