views:

72

answers:

2

Is there some type of cap as to how much CPU an applet can use? Or will my code run just as fast as a standard java program?

+2  A: 

Applets generally runs with less privilege than standard applications, but there should be no CPU cap. There have been reports of applets crashing browsers by overusing CPUs, and rather than classifying them as security flaws that need dealing with, they're simply labeled as nuisances.

That said, applets run in a variety of environment, sometimes with little consistency (that's why they're problematic, and why Java Web Start is the recommended alternative). It could very well be the case that certain applet environments impose CPU limits on applets, etc.

polygenelubricants
+1  A: 

The problem is that applets typically run as Threads in a JVM embedded in the browser. While you can adjust the priority of a Java thread, there is no way to place CPU caps on them. Indeed, I don't think you can even set CPU caps with the OS'es native threads. In the case of UNIX and UNIX-like operating systems, CPU usage limits and other limits are implemented on a per process basis.

Stephen C
PlugIn2 from 6u10 uses an out-of-browser JVM process for running applets. On some platforms threads may be considered individually for scheduling. There is a cap (of 6) of the Java thread priority, however that is often ignored when mapping to native threads (can't remember the details of platforms and versions off hand at all).
Tom Hawtin - tackline
But what you are talking about is a cap on the thread's priority, not on the amount of CPU it can use.
Stephen C