Skip to content

Instantly share code, notes, and snippets.

@pmorch
Created January 16, 2012 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmorch/1621288 to your computer and use it in GitHub Desktop.
Save pmorch/1621288 to your computer and use it in GitHub Desktop.
OpenJDK goes 100%
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}
<!DOCTYPE HTML>
<!--
This demonstrates how resizing an applet from javascript cause 100% CPU
usage indefinitely. I.e. the applet hangs. See ./HelloWorld.java for the
applet's source.
The steps I took to reproduce this:
* Boot from xubuntu-11.10-desktop-i386.iso LiveDVD
* sudo apt-get install icedtea-plugin
* Start Firefox
* Visit this index.html
* Open top in a terminal
* See that java takes up 100% CPU
-->
<html>
<head>
<title>openJDK goes 100%</title>
<style type="text/css">
body {
background-color: red;
}
applet {
/* Initial values - setTimeout sets new ones */
height: 100px;
width: 100px;
}
</style>
<script type="text/javascript"><!--
function resizeApplet(dim) {
document.getElementById('applet').style.height = dim + "px"
document.getElementById('applet').style.width = dim + "px"
}
for (var i = 1 ; i <= 4 ; i++) {
(function (local_i) {
setTimeout(function () {
resizeApplet((local_i+1)*100);
}, local_i*1000);
})(i);
}
--></script>
</head>
<body>
<applet ID="applet" CODE = "HelloWorld.class"></applet>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment