How to think about Java threads? aka Thread.stop

Exposure:

I think the Java virtual machine is awesome. This guarantees the security of bytecode, standard libraries, ... awesome, especially the ability to load a Java class on the fly and know that it cannot collapse a virtual machine (good luck with * .so files or kernel modules).

One thing I don’t understand is how Java views Thread.stop

I read http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html but this seems strange for the following reasons:

1) Resource Management

On a Unix operating system, if a process launches resources, I can kill -9.

2) Violation of abstraction:

If I run an expensive job and I no longer need to calculate, I can kill -9. As part of this Java streaming model, my computation flow should periodically check some logical flag to see if it should go out [this is like splitting abstraction layers - when I write the computation code, I should focus on the computational code, not where to lay out the checks whether it should end.

3) Security Lock / Monitors

Thus, the official reason is that "the thread contains a lock / monitor and it receives Thread.stopped? Objects will be left in damaged states" - but in the OS this is not a problem, we have interrupt handlers. Why don't Java threads have interrupt handlers that work like OS interrupt handlers?

Question:

, Java Threads . Java?

!

+3
2

, , . , "" - , ( ). -, .

, (, , ..), , SIGKILL.

+6

, .

( , , ..) - . ( ) , .

- , .

ps: , kill/kill -9, Linux. man kill , .

+2

Source: https://habr.com/ru/post/1727916/


All Articles