Created
January 16, 2012 15:11
-
-
Save pmorch/1621288 to your computer and use it in GitHub Desktop.
OpenJDK goes 100%
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.applet.Applet; | |
import java.awt.Graphics; | |
public class HelloWorld extends Applet { | |
public void paint(Graphics g) { | |
g.drawString("Hello world!", 50, 25); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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