Re: How to use power of Dual/ Quad core Processors in Applet?



Roedy Green wrote:
So long as you have multiple threads, the multiple processors will be
automatically exploited. The JVM does not assign a thread to a
processor. On each slice the OS just gives the highest priority
waiting thread to the first available processor.

pkriens wrote:
Are you sure about this? Due to the problems with multi-core memory
models I would expect a lot of Java code to fail due to lack of proper
synchronization (which also handles memory synchronization between
CPUs).

Of what "multi-core memory models" do you speak?

Java has a well-defined memory model that the JVM on any system must follow. How is its memory model subject to "the problems with multi-core memory models"? (Be specific and precise.)

Why would you expect "a lot of Java code to fail due to lack of proper synchronization" in greater proportion on multi-core systems than on single-core systems, given that both have to follow the Java Memory Model?

Do you blame Java?

nebulous99@xxxxxxxxx wrote:
Threaded code that doesn't synchronize properly will experience buggy
behavior even on single-CPU systems. Threaded Java code that does
synchronize properly should not experience buggy behavior on multi-CPU
systems ... [more accurate and cogent information followed]

Exactly. The memory model is the same. Concurrent programming is tricky. If pkriens were to actually study it, they might find that the Java Memory Model exists specifically to address issues that come up on multi-CPU systems but not on single-core systems.

So whether Roedy is sure about his assertion or not, I sure am.

--
Lew
.



Relevant Pages

  • Re: atomic operations...
    ... No MUTEXS! ... the Monitor class in .NET isn't strictly speaking a Windows mutex function). ... Until you've measured and confirmed a genuine performance problem, IMHO you should not care so much about the specific synchronization mechanism used. ... The Java implementation trades synchronization in the class itself for synchronization in the memory manager. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: is assignment atomic/thread safe?
    ... manages a user interface. ... B could consistently ignore memory updates from A as long as it ignores ... So synchronization is correct but only relatively to other modifications ... I am not trying to criticize the Java memory model. ...
    (comp.lang.java.programmer)
  • Re: About synchronization methods
    ... The Java guys themselves admit that what Java has is ... not the true monitor but some low level means to implement a monitor- ... Once you name the language, please name the one true language that is worthy enough to implement the runtimes/virtual-machine for its holiness. ... In fact, as I've pointed out before in detail, the whole "language supported" synchronization model of Java is nothing more than very shallow semantic sugar over the standard library mutex and condition variable synchronization model. ...
    (comp.programming.threads)
  • Re: Compiling 5.0 syntax java files
    ... Less well known but arguably more important were the addition of the java.util.concurrent and related packages, and the cleanup of the so-called "memory model" for multi-threaded programs. ... The memory model in Java 1.4 and prior had some subtle issues that tended to show up more frequently in multi-processor architectures. ... it is not entirely unreasonable to maintain a Java 1.3 platform. ... If you aren't encountering weird concurrency bugs and your productivity is acceptable, it's understandable the boss is reticent to make a change. ...
    (comp.lang.java.programmer)
  • Re: Compiling 5.0 syntax java files
    ... Less well known but arguably more important were the addition of the java.util.concurrent and related packages, and the cleanup of the so-called "memory model" for multi-threaded programs. ... The memory model in Java 1.4 and prior had some subtle issues that tended to show up more frequently in multi-processor architectures. ... it is not entirely unreasonable to maintain a Java 1.3 platform. ... If you aren't encountering weird concurrency bugs and your productivity is acceptable, it's understandable the boss is reticent to make a change. ...
    (comp.lang.java.programmer)