The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
A Java applet runs in the context of a browser. Java小程序在浏览器的上下文中运行。The Java Plug-in software in the browser controls the launch and execution of Java applets. 浏览器中的Java插件软件控制Java小程序的启动和执行。The browser also has a JavaScript interpreter, which runs the JavaScript code on a web page. 浏览器还有一个JavaScript解释器,可以在网页上运行JavaScript代码。This topic describes the behavior of the Java Plug-in software released in Java Platform, Standard Edition 6 update 10.本主题描述Java平台Standard Edition 6 update 10中发布的Java插件软件的行为。
The Java Plug-in software creates a worker thread for every Java applet. Java插件软件为每个Java小程序创建一个工作线程。It launches an applet in an instance of the Java Runtime Environment (JRE) software. 它在Java运行时环境(JRE)软件的实例中启动一个小程序。Normally, all applets run in the same instance of the JRE. 通常,所有小程序都在同一个JRE实例中运行。The Java Plug-in software starts a new instance of the JRE in the following cases:Java插件软件在以下情况下启动JRE的新实例:
An applet will run in an existing JRE if the following conditions are met:如果满足以下条件,小程序将在现有JRE中运行:
The following diagram shows how applets are executed in the JRE.下图显示了小程序在JRE中的执行方式。
Java applets can invoke JavaScript functions present in the web page. Java小程序可以调用网页中的JavaScript函数。JavaScript functions are also allowed to invoke methods of an applet embedded on the same web page. JavaScript函数还可以调用嵌入在同一网页上的小程序的方法。The Java Plug-in software and the JavaScript interpreter orchestrate calls from Java code to JavaScript code and calls from JavaScript code to Java code.Java插件软件和JavaScript解释器协调从Java代码到JavaScript代码的调用,以及从JavaScript代码到Java代码的调用。
The Java Plug-in software is multi-threaded, while the JavaScript interpreter runs on a single thread. Java插件软件是多线程的,而JavaScript解释器在单个线程上运行。Hence, to avoid thread-related issues, especially when multiple applets are running simultaneously, keep the calls between Java code and JavaScript code short, and avoid round trips, if possible. See the following topics to find out more about interactions between Java code and JavaScript code:因此,为了避免与线程相关的问题,尤其是当多个小程序同时运行时,请尽量缩短Java代码和JavaScript代码之间的调用,并尽可能避免往返。有关Java代码和JavaScript代码之间交互的更多信息,请参阅以下主题: