Multiple Thread access

If multiple threads are accessing a shared resource,

I am using the wait() and notifyAll() methods for

interthread communications.

My query is:

Is the thread that has now got the Object's monitor

takes a long time to do a processing or encounters

an error,what happens to the other threads waiting

in the queue?

How long will the other threads wait for?

Is there a solution to the above problem?

Thanks

[470 byte] By [bhuru_luthriaa] at [2007-10-3 9:41:49]
# 1
The other threads have to wait till the executing thread releases the lock.Kaj
kajbja at 2007-7-15 4:57:58 > top of Java-index,Java Essentials,Java Programming...
# 2
But then,if the other threads are waiting for the lock to be released,and the thread that has acquired a lock, has a problem, then is therea way around it rather than the other threads waiting?
bhuru_luthriaa at 2007-7-15 4:57:58 > top of Java-index,Java Essentials,Java Programming...
# 3
> But then,if the other threads are waiting for the> lock to be released,> and the thread that has acquired a lock, has a> problem, then is there> a way around it rather than the other threads waiting?Nope
kajbja at 2007-7-15 4:57:58 > top of Java-index,Java Essentials,Java Programming...
# 4
.. I haven't used the new Lock implementations in Java 5, one of them might help you.
kajbja at 2007-7-15 4:57:58 > top of Java-index,Java Essentials,Java Programming...
# 5

To get above this problem, if I create a Thread Pool

to process incoming requests, and lets suppose that

Thread 1(T1) is processing Request 1(R1),

and T2 is processing R2 and so on.

If T1 encounters a problem, but T2 has successfully processed T2,

then isnt this a better way for the problem where all threads are

waiting ?

bhuru_luthriaa at 2007-7-15 4:57:58 > top of Java-index,Java Essentials,Java Programming...
# 6

What you should be looking at is locking the resource for the minumum necessary portion of the processing. How well you can do this, of course, rather depends on the nature of the resource we're talking about.

You may be able to buffer access with queues, for example, doing all the actual handling of the resource with one thread.

malcolmmca at 2007-7-15 4:57:58 > top of Java-index,Java Essentials,Java Programming...