Image

Порой в стороннем коде встречается удивительное. Не мог бы кто нибудь обьяснить есть ли смысл в написаном ?
Не обращая внимание на отсутвие генериков (я убрал для простоты), неумение пользовать this outer класса (а это уже не я) и тп - есть ли хоть какой малейший резон в подобном надругательстве над ThreadPoolExecutor ?


        ....
	public void init()
	{
		eventQueue = new LinkedBlockingQueue();
		workers = Executors.newFixedThreadPool(getThreadPoolSize());
		for (int ii=0; ii < getThreadPoolSize(); ii++)
		{
			workers.execute(new Processor(eventQueue, this));
		}
	}
        ....
        // это метод лыстенера получения сообщений.
	public void receiveMessage(Serializable message) 
	{
            eventQueue.add(message);
	}
        
        public void processMessage(Serializable message)
        {
             // здесь длинный метод процессинга.
        }
        ...

	class Processor implements Runnable 
	{
		LinkedBlockingQueue queue = null;
		ClassOfThis parent = null;
		
		public ClassificationProcessor(LinkedBlockingQueue queue,ClassOfThis parent)
		{
			this.queue = queue;
			this.parent = parent;
		}
		
		public void run()
		{
                        Serializable msg;
			while (parent.keepRunning)
			{
				try
				{
					msg = queue.take();
					(Serializable)parent.processMessage(msg);
				}
				catch (InterruptedException ie)
				{
					// ignore
				}
				catch (Throwable e)
				{
				       // логать ошибку
				}
			}
		}
	}