An old Question about Multi Processing of Applets?

S

Sanny

I asked this question earlier but do not get a proper answer to it.

I want to know If I assign 10 threads in an Applet and run it on a 8-
core CPU will the threads in the Applet run in Parallel???

Some said Browers window will get Only 1 CPU.

Some said depends on Browser

Some said Threads will get seperate Processors.

So I wanted to know the answer and I got all the three answers. Here
are the Browsers I am Concerned with.

1. Internet Explorer
2. Netscape
3. FireFox.
4. Any other important Browser.

Since 90% people use any of the above browsers.

I know An Application run on 8 core processor then all threads will
get seperate Processor, But I want to know What happens when an Applet
is running on a Browser.

Bye
Sanny
 
S

Sanny

One thing I am cocerned is that Applet is run by JVM [Java Virtual
Machine]

Will that JVM take care of threads and give the applet access to all
CPUs???

Or this JVM can access only 1 Processor that is alloted to it by
Browser.

I read somewhere that Browser use only 1 CPU. Even if you open 5
Websites on a Browser, All pages will only use only 1 CPU.

What a waste of Resouce. Imagine you have 8core CPU and you are
browsing 8 webpages and all of them getting just 1 CPU.

Here is an Article that Discusses it. [Very Interesting]
http://pinderkent.blogsavy.com/archives/147


COPY PASTE START---------------->>>>>
When it comes to purchasing consumer-grade PCs these days, it's rare
to find a system with a CPU that only has a single core. Most laptops
even offer a dual-core CPU. So as software developers, we're entering
a unique era where we can start to employ parallelism in ways that
would not have been practical before. In some cases, we will need to
exploit this parallelism if we hope to increase the performance of our
software.

Unfortunately, we are also seeing a move towards the development and
use of Web-based applications. These are applications that are hosted
on a remote server, and provide an HTML- and AJAX-based interface that
is accessed via a Web browser.

These Web browsers attempt to give us some degree of parallelism,
often through tabbed browsing. While this works great for relatively
static content, we experience problems with JavaScript scripts that
run for anything longer than 500 ms or so. Since the computation of
all of the tabs is performed within the same (main) thread of the
browser, a long-running JavaScript script immediately locks up all of
the other tabs.

The solution is quite clear: each browser tab should have its own
thread, in which a separate instance of a JavaScript interpreter
executes. A long-running JavaScript script in one tab (ie. one that
runs for 2 to 3 seconds, if not more) will not prevent, at the very
least, the user from switching to an alternate tab and continuing to
work there.

Of course, most Web browsers today just aren't prepared for such an
architectural change. And considering how large of a job it is to
write a high-quality browser, it seems unlikely that we'll see a Web
browser written from the ground up that better supports the benefits
offered by the now-prevalent multi-core CPUs. So it's quite
unfortunate that we have all of this processing power available to us,
but it can only be exploited to a limited degree because developers
are choosing to write JavaScript-based applications that execute
within parallelism-unfriendly Web browsers.

COPY PASTE END--------------->>>>>>>


Bye
Sanny
 
E

EJP

Sanny said:
I asked this question earlier but do not get a proper answer to it.

I want to know If I assign 10 threads in an Applet and run it on a 8-
core CPU will the threads in the Applet run in Parallel???

Some said Browers window will get Only 1 CPU.

They were wrong.
Some said depends on Browser

They were wrong. It depends on the JVM.
Some said Threads will get seperate Processors.

Possibly, possibly not.
So I wanted to know the answer and I got all the three answers. Here
are the Browsers I am Concerned with.

The browser is irrelevant. It depends on the JVM. The JVM and/or the OS
will allocate threads to processors, in ways which you can't control,
but which it/they will consider optimal.
I know An Application run on 8 core processor then all threads will
get seperate Processor

No you don't. See above.
But I want to know What happens when an Applet is running on a Browser.

Makes no difference. It's still a JVM in there.
 
R

Roger Lindsjö

Sanny said:
One thing I am cocerned is that Applet is run by JVM [Java Virtual
Machine]

Will that JVM take care of threads and give the applet access to all
CPUs???

Perhaps, that depends on the JVM and the OS.
Or this JVM can access only 1 Processor that is alloted to it by
Browser.

If the browser is fored to only used one CPY, then it could very well be
tthat the JVM is also forced to only use one CPU.
I read somewhere that Browser use only 1 CPU. Even if you open 5
Websites on a Browser, All pages will only use only 1 CPU.

What a waste of Resouce. Imagine you have 8core CPU and you are
browsing 8 webpages and all of them getting just 1 CPU.

Here is an Article that Discusses it. [Very Interesting]
http://pinderkent.blogsavy.com/archives/147

That article talks about JavaScript, very different from Java.
 
R

Roger Lindsjö

Sanny said:
I asked this question earlier but do not get a proper answer to it.

I want to know If I assign 10 threads in an Applet and run it on a 8-
core CPU will the threads in the Applet run in Parallel???

Some said Browers window will get Only 1 CPU.

Some said depends on Browser

Some said Threads will get seperate Processors.

So I wanted to know the answer and I got all the three answers. Here
are the Browsers I am Concerned with.

1. Internet Explorer
2. Netscape
3. FireFox.
4. Any other important Browser.

Since 90% people use any of the above browsers.

What's wrong with those different answers? It most likely depends on the
JVM and the OS and less likely on the browser. In an other post you
referred to JavaScript (very different from Java) and most browsers run
them single threaded as far as I know.
I know An Application run on 8 core processor then all threads will
get seperate Processor, But I want to know What happens when an Applet
is running on a Browser.

That is a possible outcome, but they might also not get a processor /
core each for at least the following reasons:
* Other programs compete for the same resources.
* You as a user are any allowed access to a subset of the processors.
* The application is only allowed access to a subset of the processors.
* The JVM can not utilize all processors (not likely on a modern JVM
unless you have a lot of processors).
 
K

Knute Johnson

Sanny said:
I asked this question earlier but do not get a proper answer to it.

I want to know If I assign 10 threads in an Applet and run it on a 8-
core CPU will the threads in the Applet run in Parallel???

Some said Browers window will get Only 1 CPU.

Some said depends on Browser

Some said Threads will get seperate Processors.

So I wanted to know the answer and I got all the three answers. Here
are the Browsers I am Concerned with.

1. Internet Explorer
2. Netscape
3. FireFox.
4. Any other important Browser.

Since 90% people use any of the above browsers.

I know An Application run on 8 core processor then all threads will
get seperate Processor, But I want to know What happens when an Applet
is running on a Browser.

Bye
Sanny

I ran a test with the following code on Windows XP with a Pentium D
processor with both FireFox and IE7. In both cases both processors were
used. Of course this is not conclusive and it probably depends on the
JVM and available resources. But at least you know under this
circumstance that multiple processors were used in a browser.

import java.applet.*;
import java.awt.*;

public class PTestApplet extends Applet implements Runnable {
volatile boolean flag = true;
volatile Thread one,two;

public void init() {
one = new Thread(this);
two = new Thread(this);
}

public void start() {
one.start();
two.start();

Runnable r = new Runnable() {
public void run() {
try {
Thread.sleep(10000);
} catch (InterruptedException ie) { }
flag = false;
}
};
new Thread(r).start();
}

public void run() {
while (flag) {
for (int i=0; i<100000; i++) ;
}
}

public void stop() {
flag = false;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top