Celestino, This 'cloning' is essentially what the JVM does for you when you use synchronized code: it also makes sure that no other synchronized thread is modifying the underlying array. I would probably run a few tests to verify that your own code is significantly faster(and less resource intensive) before you go to a 'roll your own' solution. Then again, it might indeed be faster.
All best, M -----Original Message----- From: Celestino Bellone [mailto:[EMAIL PROTECTED] Sent: Monday, June 23, 2003 12:25 PM To: Regexp Users List Subject: Re: problem with massive use Hi Sushil Thanks for your response. I've tried another method to make "thread-safe" my class and it's (I think) faster than synchronization. I've cloned (at runtime, into my method) the RE array when I used it. Then every process has own array, and I think that's the faster way... Obviously I hope that the Garbage Collector works properly (I've also assigned to "null" the array after the usage)... ;-) bye Celestino ----- Original Message ----- From: Sureka, Sushil To: 'Regexp Users List' Sent: Monday, June 23, 2003 6:13 PM Subject: RE: problem with massive use I have run into the similar problem before. The issue was basically that RE code is not thread safe (In javadoc they go in details about it, in short it is for performance reasons). Please make sure that the call to match() is inside a synchronized block and that should take care of the issue. Sushil -----Original Message----- From: Celestino Bellone [mailto:[EMAIL PROTECTED] Sent: Monday, June 23, 2003 8:31 AM To: [EMAIL PROTECTED] Subject: problem with massive use Hi everybody I've developed (with my colleagues) a RE-based java class (named CalcoloCodice) that evaluates a string and returns a "code" strictly dependentent on the string. The class contains different static String arrays (the expressions) that, via a static initializer, are converted into RE arrays. At runtime, the application calls a CalcoloCodice's static method that calls the match() method for every regexp until a code is found (and exits if anything is found) returning the result code. Occasionally (with no apparent reason), when there are a lot of users that uses the application, the following exception are trown by RE class: java.lang.StringIndexOutOfBoundsException: String index out of range: 7 at java.lang.String.charAt(String.java:516) at org.apache.regexp.StringCharacterIterator.charAt(StringCharacterIterator.jav a:90) at org.apache.regexp.RE.matchNodes(RE.java:1209) at org.apache.regexp.RE.matchAt(RE.java:1448) at org.apache.regexp.RE.match(RE.java:1498) at org.apache.regexp.RE.match(RE.java:1468) at org.apache.regexp.RE.match(RE.java:1561) There are some people that can help me? Thanks a lot in advance Celestino P.S.: excuse me for my poor English... ;-) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]