java – How are threads different from threads?

Question:

It seems like it should be the same thing, since thread is translated both as a "thread" and as a "thread". It seems like, when creating a thread (thread) and the last launch, it can break into threads?

Does this thread spawn its own kind (threads are the same as it does) or does it spawn threads (which are apparently inferior threads)?

Also, are the read (from the console, file) and output (to file) streams the same?

Why then do we not call their start methods, etc., but only close ?

Or is it possible to start a thread by just creating an object of their type?

Are they all the same streams? And yet, the presence of 2 threads with a thread and with a runnable is due to the fact that it is impossible to inherit from the first one, but it is easier to run, and from the second thread it is possible to inherit, but is it more difficult to run?

Answer:

It seems like it should be the same thing, maybe thread is translated this way and that.

Same. Now, if you come across the term Fiber, everything is a little more interesting there, interaction with it occurs as with a stream, but it is not a classic OS stream.

It seems like, when creating a thread (thread) and the last launch, it can break into threads?

It cannot break, but it can generate. Spawned threads have exactly the same capabilities.

Also, are the read (from the console, file) and output (to file) streams the same?

No, we are talking about threads of execution, and these are data streams, i.e. just sequential swapping of bytes from one place to another.

And yet, the presence of 2 threads with thread and with runnable is due to the fact that it is impossible to inherit from the 1st one, but it is easier to run, and from the 2nd thread it is possible to inherit, but is it more difficult to run?

I don’t presume to judge the architects of the API, but you should never inherit from the stream class at all. In most cases, you generally need an ExecutorService, which will take over the control of threads, and you will simply give it tasks for execution in the form of a Runnable or an analogue.

Scroll to Top