Jeremy,

I think it could be a dual core issue. Anyway, I have removed the wait
of the work item's monitor between the caller and the worker threads. I
call workAccepted just before the scheduling the work. I know it is not
ideal, however, it is a fairly safe assumption given the behaviour of
Executors.newFixedThreadPool method that the work would never be
rejected because of the backing unbounded queue. Please find the  patch
attached.

Ta
Meeraj



-----Original Message-----
From: Jeremy Boynes [mailto:[EMAIL PROTECTED] 
Sent: 25 July 2006 00:21
To: [email protected]
Subject: Re: [jira] Created: (TUSCANY-573) Race condition in
ThreadPoolWorkManager

On Jul 24, 2006, at 12:41 PM, Meeraj Kunnumpurath wrote:

> Jeremy,
>
> Pls find the patch attached.
>

Unfortunately this appears to deadlock on my Mac (maybe a dual-core
problem).

--
Jeremy


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


This message has been checked for all email viruses by MessageLabs.




*****************************************************

    You can find us at www.voca.com

*****************************************************
This communication is confidential and intended for 
the exclusive use of the addressee only. You should 
not disclose its contents to any other person.
If you are not the intended recipient please notify 
the sender named above immediately.

Registered in England, No 1023742,
Registered Office: Voca Limited
Drake House, Three Rivers Court,
Homestead Road, Rickmansworth,
Hertfordshire, WD3 1FX


This message has been checked for all email viruses by MessageLabs.
Index: ThreadPoolWorkManager.java
===================================================================
--- ThreadPoolWorkManager.java  (revision 425093)
+++ ThreadPoolWorkManager.java  (working copy)
@@ -79,11 +79,11 @@
     public WorkItem schedule(Work work, WorkListener workListener) throws 
WorkRejectedException {
 
         DefaultWorkItem workItem = new DefaultWorkItem(new UID().toString(), 
work);
+        if (workListener != null) {
+            workItems.put(workItem, workListener);
+        }
+        workAccepted(workItem, work);
         if (scheduleWork(work, workItem)) {
-            if (workListener != null) {
-                workItems.put(workItem, workListener);
-            }
-            workAccepted(workItem, work);
             return workItem;
         } else {
             workItem.setStatus(WorkEvent.WORK_REJECTED);
@@ -198,7 +198,7 @@
          * Overrides the run method.
          */
         public void run() {
-            workStarted(workItem, decoratedWork);
+                       workStarted(workItem, decoratedWork);
             try {
                 decoratedWork.run();
                 workCompleted(workItem, decoratedWork);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to