简体   繁体   English

Java应用程序服务器执行堆栈线程相似性

[英]Java application servers execution stack thread affinity

Let's say we have Spring Boot application deployed under Tomcat or another app server. 假设我们已经在Tomcat或其他应用程序服务器下部署了Spring Boot应用程序。

Let's say the app is running and has some method execution stack. 假设该应用正在运行,并且具有一些方法执行堆栈。 Is it possible execution stack can be transferred by App Server between threads within App Server built-in Thread Pool? App Server是否可以在App Server内置线程池中的线程之间转移执行堆栈?

Ie can Thread Id will change within same execution stack of application (not internal app server stack)? 即线程ID是否可以在同一应用程序执行堆栈(而不是内部应用程序服务器堆栈)内更改? Consider example: 考虑示例:

class FooBar {

  fooBar() {
    foo()
    bar()
  }

  foo() {}

  bar() {}

}

Can it happen that App server will make method bar() run in Thread ID 1 and method foo() is run in Thread ID 2 when fooBar() started in Thread ID 1? 当在线程ID 1中启动fooBar()时,App服务器是否可能使方法bar()在线程ID 1中运行而方法foo()在线程ID 2中运行?

Warning: This is a tricky question and App servers do unexpected things which are contrary to the normal understanding of how JVM works. 警告:这是一个棘手的问题,App服务器执行意外的操作,这与对JVM工作原理的正常理解背道而驰。

No 没有

It is impossible to change thread of running (or blocked) code. 不可能更改正在运行(或已阻止)代码的线程。

PS: While app servers some time do tricky things they unable to brake JVM constraints (until they doesn't provide their own JVM with non standard behavior). PS:虽然应用服务器有时会做一些棘手的事情,但它们无法克服JVM的限制(直到它们没有为自己的JVM提供非标准行为)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM