[ htmlunit-Bugs-1584525 ] ThreadManager not thread safe

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ htmlunit-Bugs-1584525 ] ThreadManager not thread safe

SourceForge.net
Bugs item #1584525, was opened at 2006-10-25 17:42
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1584525&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: 1.8
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: kkolman (kkolman)
Assigned to: Nobody/Anonymous (nobody)
Summary: ThreadManager not thread safe

Initial Comment:
The ThreadManager class
(com.gargoylesoftware.htmlunit.ThreadManager) is not
thread safe. The static integer property NextThreadID_
is accessed in a not thread safe way:

the startThread(final Runnable job) method contains the
following code:

final int myThreadID = NextThreadID_++;

this code is not thread safe (two threads can recieve
the same ID)

the code should be

final int myThreadID;
synchronized (ThreadManager.class) {
  myThreadID = NextThreadID_++;
}

Moreover, there is no need for the NextThreadID_
property to be static, the synchronized block would than be

synchronized (this) {
  myThreadID = NextThreadID_++;
}


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1584525&group_id=47038

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop