avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject RE: Performance questions about ECM
Date Sat, 09 Mar 2002 14:41:39 GMT

> From: Vincent Massol [mailto:vmassol@octo.com]
> I agree with all you have said. However, my biggest fear (and you have
> not yet convinced me !) is that even though synchronization is fast it
> will still block *all* threads during that time.

So you mean that:

class WorkerThread extends Thread {
    int number;
    Hack hack;
    public WorkerThread (int number, Hack hack) {
        this.number = number;
        this.hack = hack;
    public void run () {
        switch (number) {
        case 0:
        case 1:
        case 2:

public class Hack {
    public synchronized void syncMethod () {
        System.out.println ("entering sync method");
        try {
            Thread.sleep (1000);
        } catch (Throwable t) {
        System.out.println ("leaving sync method");
    public void method () {
        for (int i = 0; i < 10; i++) {
            System.out.println ("in method");
            try {
                Thread.sleep (200);
            } catch (Throwable t) {
    public static void main (String args[]) throws Exception {
        new Hack().run();
    public void run () throws Exception {
        WorkerThread thread[] = new WorkerThread[3];
         thread[0] = new WorkerThread (0, this);
         thread[1] = new WorkerThread (1, this);
         thread[2] = new WorkerThread (2, this);
        for (int i = 0; i < 3; i++) {
        for (int i = 0; i < 3; i++) {

The third worker thread will stop while the second or first
compete for the monitor of syncMethod()? (Answer: no.) I'm not
quite sure that I follow you here...

A thread will only block if it is actually waiting for a 

> Object creation may
> take a bit longer but they won't block any other thread. So I'm more
> worried about synchronization.

And you are sure that there aren't any locks associated with the 
common java heap or the object nurseries?

To answer your question: No. I know of no such CM implementation, and
if you need one I suspect you will have to roll your own.

I also think that you are wasting your time doing so, as your SQL
queries probably have X synchronizations associated with them, and
as the VM itself probably has a set of locks inside it that you have
no control over. Not to mention the locks in the OS and networking 

Do not take the above paragraph as criticism of your skill. Your system
works - that's undeniable and proof enough that you know what you are 
doing. But I do not see how synchronization could
cause you significant slowdown compared to the cascading object
creation your single-threaded components produce. Remember, that
cascade goes through the ECM's synchronization as well. If you
removed the sync, all you would remove is the time it takes to aquire
a monitor. If you removed the cascade of object creation, you'd lose
that, as well as object creation times.


To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message