Java应用程序开始执行时,这些线程会受到哪些刺激? [英] What are these threads which are spwaned when a Java application begins its execution?

查看:74
本文介绍了Java应用程序开始执行时,这些线程会受到哪些刺激?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的Java应用程序,其中包含一个JFrame和几个JButton.当我尝试使用JVMTI检查Java应用程序时,我发现虽然我没有创建任何显式线程,但是却产生了许多显式线程.

I have created a simple Java application which has a JFrame and few JButtons. When I tried to inspect the java application using JVMTI I found that though I did not create any explicit threads there were lot of them spawned.

我可以找到以下线程:

  • 销毁JavaVM
  • AWT-EventQueue-0
  • 关闭关机
  • AWT-XAWT-守护程序线程
  • Java2D Disposer-守护程序线程
  • 线程-0-守护程序线程[由JVMTI代理创建]
  • Signal Dispatcher-守护程序线程
  • 最终化-守护进程线程
  • 引用处理程序-守护程序线程

其中大多数处于可运行状态.有人可以告诉我这些线程的功能吗?

Most of them were in Runnable state. Can someone tell me the function of these threads?

推荐答案

基础库使用这些线程来管理图形应用程序所需的小部件,显示,事件循环和其他管道.

These threads are used by the underlying libraries to manage the widgets, display, event-loop, and other plumbing that is needed for your graphical application.

GUI应用程序通常具有很多活动的部分,如果您已经注意到您不必显式编写任何代码来管理这些部分(例如,更新屏幕,绘制按钮或处理鼠标)移动).这是一组后台线程,负责管理这些部分,并使您尽可能轻松地专注于应用程序逻辑.

A GUI application usually has a lot of moving parts, and if you've noticed you don't have to explicitly write any code to manage these parts (e.g., updating the screen, or drawing a button, or handling a mouse movement). Is is this set of background threads that are responsible for managing these parts, and making it as easy as possible for you to focus on your application logic.

这些线程由您使用的库(例如AWT,Swing等)产生,通常在终止时清理它们自己(以及它们管理的资源).

These threads are spawned by the libraries that you use (e.g., AWT, Swing, etc.) and usually clean themselves (and the resources that they manage) up upon termination.

这篇关于Java应用程序开始执行时,这些线程会受到哪些刺激?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆