Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are running out of stack consider creating a dedicate thread w/ enough stack especially for running the request. Sample code below.</p> <pre><code>package t1; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.regex.Pattern; public class RegExpRunner { ExecutorService svc; public RegExpRunner(long stackSize){ init(stackSize); } void init(long stackSize){ final SynchronousQueue&lt;Runnable&gt; queue = new SynchronousQueue&lt;Runnable&gt;(); svc = new ThreadPoolExecutor(1, 2, 60, TimeUnit.SECONDS, queue, createThreadFactory(stackSize), new RejectedExecutionHandler(){//wait if there is a concurrent compile and no available threads @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { try{ queue.put(r); }catch(InterruptedException _ie){ Thread.currentThread().interrupt(); throw new IllegalStateException(_ie); } } }); } private ThreadFactory createThreadFactory(final long stackSize) { return new ThreadFactory(){ final ThreadGroup g = Thread.currentThread().getThreadGroup(); private final AtomicLong counter= new AtomicLong(); { //take care of contextClassLoader and AccessControlContext } @Override public Thread newThread(Runnable r) { Thread t = new Thread(g, r, composeName(r), stackSize); return t; } protected String composeName(Runnable r) { return String.format("Regexp dedicated compiler: %d @ %tF %&lt;tT ", counter.incrementAndGet(), System.currentTimeMillis()); } }; }; public Pattern compile(final String regex){//add flags if you need 'em Callable&lt;Pattern&gt; c = new Callable&lt;Pattern&gt;(){ @Override public Pattern call() throws Exception { return Pattern.compile(regex); } }; try{ Pattern p = svc.submit(c).get(); return p; }catch(InterruptedException _ie){ Thread.currentThread().interrupt(); throw new IllegalStateException(_ie); } catch(CancellationException _cancel){ throw new AssertionError(_cancel);//shan't happen } catch(ExecutionException _exec){ Throwable t = _exec.getCause(); if (t instanceof RuntimeException) throw (RuntimeException) t; if (t instanceof Error) throw (Error) t; throw new IllegalStateException(t==null?_exec:t); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload