>> When you write Thread t = new MyThread(); r.start(), do you get a new
>> thread (you know like in Linux you call pthread_create() and kernel
[quoted text clipped - 7 lines]
> a lightweight threading package, or by having a single-threaded
> interpreter round-robin among the active threads is left open.
Furthermore, the whole point of java is not having to worry about stuff
like this. If you do, you're probably either using the wrong tool (try
C++) or going about your problem the wrong way. There may be legitimate
reasons to rely on this information in java, but I can't think of any.
Arne Vajhøj - 20 Aug 2006 20:12 GMT
> Furthermore, the whole point of java is not having to worry about stuff
> like this. If you do, you're probably either using the wrong tool (try
> C++) or going about your problem the wrong way. There may be legitimate
> reasons to rely on this information in java, but I can't think of any.
It can be very relevant to know the implementation of
Java threads on ones platform for both application,
operating system and hardware configuration.
Arne
Patricia Shanahan - 20 Aug 2006 21:21 GMT
>>> When you write Thread t = new MyThread(); r.start(), do you get a new
>>> thread (you know like in Linux you call pthread_create() and kernel
[quoted text clipped - 11 lines]
> C++) or going about your problem the wrong way. There may be legitimate
> reasons to rely on this information in java, but I can't think of any.
What about programs that need more than one second of CPU time per
second of elapsed time? Multiple OS threads can run on different
processors at the same time. A single OS thread can never get more than
one processor.
Patricia
Mike Schilling - 20 Aug 2006 23:02 GMT
>>>> When you write Thread t = new MyThread(); r.start(), do you get a
>>>> new thread (you know like in Linux you call pthread_create() and
[quoted text clipped - 17 lines]
> processors at the same time. A single OS thread can never get more
> than one processor.
Yes. If the OP's question were qualified to be asking about a specific Java
implementation (including version), it could be answered in detail, and that
detail might be of real importance. It's a fallacy to conclude from "Java
can be used to write very portable applications" that "Java should *only* be
used to write very portable applications."
Chris Uppal - 21 Aug 2006 10:52 GMT
> Furthermore, the whole point of java is not having to worry about stuff
> like this. If you do, you're probably either using the wrong tool (try
> C++) or going about your problem the wrong way. There may be legitimate
> reasons to rely on this information in java, but I can't think of any
Unfortunately, that is almost completely untrue. In an ideal world it /would/
be true, but this is not that world...
The design space which can be approached by "green" threads has only a small
overlap with the design space which is suitable for OS-level threads -- unless
the OS itself provides light-weight threads, and that is in general /not/ the
case (there are exceptions).
If you are only using a small number of threads, and do not care greatly about
the amount of actual concurrency you achieve -- i.e you are using the threads
only as a code structuring mechanism -- then it makes little difference how the
threads are implemented. For all the other cases, you do have to care, and you
may be forced to use /very/ different designs for your application depending on
how threads are implemented.
-- chris
>> When you write Thread t = new MyThread(); r.start(), do you get a new
>> thread (you know like in Linux you call pthread_create() and kernel
[quoted text clipped - 5 lines]
> lightweight threading package, or by having a single-threaded interpreter
> round-robin among the active threads is left open.
It would probably be impossible to define something like this
in the Java standard, because Java runs on so many different
platform.
But I believe that recent Java versions for common platforms
tend to map Java threads to native threads 1:1.
Some Java implementations has a -X or -XX switch to specify
the threading model to use.
Arne
Martin Gregorie - 20 Aug 2006 22:13 GMT
>>> When you write Thread t = new MyThread(); r.start(), do you get a new
>>> thread (you know like in Linux you call pthread_create() and kernel
[quoted text clipped - 12 lines]
> But I believe that recent Java versions for common platforms
> tend to map Java threads to native threads 1:1.
That's been true for Sun's JDK for Linux from at least version 1.3 - its
easy to prove: start a Java app from one console window, switch to
another, type "ps -u/username/" and look at all the processes[1] with
the same name as the Java app.
[1] Like most Unices, Linux uses the same mechanism to schedule and
execute both threads and processes.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |