Though I would just add the current example implementation I am using.  Feel
free to give comments.

RouteBuilder :

> RouteBuilder builder = new RouteBuilder() {
>       public void configure() {
>               PriorityThreadFactory highPriorityThreadFactory = new
> PriorityThreadFactory(Thread.MIN_PRIORITY);
>               ExecutorService recipeDealStoreOfferGeneratorExecutorService =
> Executors.newFixedThreadPool(1, highPriorityThreadFactory);
>               from("timer://foo?delay=2000&period=1&repeatCount=3")
>               
> .threads().executorService(recipeDealStoreOfferGeneratorExecutorService)
>                       .process(new Processor() {
>                               @Override
>                               public void process(Exchange exchange) throws 
> Exception {
>                                       // Long Running Process
> 
>                                       long startTime = 
> System.currentTimeMillis();
> 
>                                       Long value = 0L;
>                                       while (value < 2000000000L) {
>                                               value++;
>                                       }
>                                       
> System.out.println("Thread.getPriority(): " +
> Thread.currentThread().getPriority());
>                                       System.out.println("Processed in: " + +
> (int)((System.currentTimeMillis()-startTime)/1000.0) + " s");
>                               }
>                       });
>       }
> };

PriorityThreadFactory:

> public class PriorityThreadFactory implements ThreadFactory {
> 
>     final int priority;
> 
>     public PriorityThreadFactory() {
>         this.priority = Thread.NORM_PRIORITY;
>     }
> 
>     public PriorityThreadFactory(int priority) {
> 
>         if (priority < Thread.MIN_PRIORITY) {
>             this.priority = Thread.MIN_PRIORITY;
>         } else if (priority > Thread.MAX_PRIORITY) {
>             this.priority = Thread.MAX_PRIORITY;
>         } else {
>             this.priority = priority;
>         }
>     }
> 
>     @Override
>     public Thread newThread(Runnable r) {
>         Thread thread = new Thread(r);
>         thread.setPriority(priority);
>         return thread;
>     }
> 
> }





--
View this message in context: 
http://camel.465427.n5.nabble.com/Thread-pool-profiles-Thread-currentThread-setPriority-MIN-PRIORITY-tp5754039p5755587.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to