[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Declaration and deployment of threads and thread pools i

david.lloyd@jboss.com do-not-reply at jboss.com
Thu Nov 6 08:32:10 EST 2008


"adrian at jboss.org" wrote : Why are you using float for thread priority?
  | A thread can only take an integer priority between 
  | 1 (Thread.MIN_PRIORiTY) and 10 (Thread.MAX_PRIORITY)

I got the notion in my head that MAX_PRIORITY might not be 10, so my thought was to take a float between 1.0 and 10.0 inclusive and scale it between MIN and MAX.  Though I guess I overthought it, since if someone decided to arbitrarily change the priority scale, there would probably be compatibility issues, so that would seem to be a rather unlikely scenario.

"adrian at jboss.org" wrote : Even if it was a decimal, BigDecimal would be better than float because of the rounding errors.

I doubt that someone would care if their thread at priority 10.1 was really running at 10.099999999999999644728632119950, since it would very likely end up being the same priority value anyway :-)

In any case, making this a float was probably a dumb idea - I think I'll just make it an int.

"adrian at jboss.org" wrote : But there are also some different policies such as MinThreadPoolExecutor so you can avoid the known race condition if you implement a WAIT policy when the thread pool is full (something that is not part of java.util.concurrent because of the race condition)

I saw the code and the comment to that effect, but at first glance it wasn't clear what the race condition was, or how the fix worked.  I'll have to look at that one more time...

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4187342#4187342

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4187342



More information about the jboss-dev-forums mailing list