2 Replies - 1275 Views - Last Post: 06 July 2014 - 01:57 PM Rate Topic: -----

#1 synchronization   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-July 14

TaskExecutor is a service that accepts instances of Tasks

Posted 06 July 2014 - 01:51 PM

TaskExecutor Service
The TaskExecutor is a service that accepts instances of Tasks (classes implementing the Task interface) and executes each task in one of the multiple threads maintained by the service. That is, the service maintains a pool of pre-spawned threads that are used to execute Tasks.
Typically, a single instance (i.e. the Singleton design pattern) of the TaskExecutor implementation would be installed on the application utilizing the service. The application would avoid creating multiple instances of the TaskExecutor service as that defeats the reason for building service and utilizing pooled threads.
The following figure gives an overview of the structure and possible design of the service. Clients provide implementation of the Task interface which performs some application-specific operation. Clients utilize the addTask() method to add these tasks to the FIFO queue. Pooled threads remove the tasks from the queue and execute the Taskís execute() method. The application-specific Task executes for some amount of time before completing by returning from the execute() method. At this point the thread attempts to obtain a new Task from the queue. If the FIFO queue is empty (no tasks to execute) the threadís execution must be blocked until a new task is added to the queue.

1. The project will provide an implementation of the provided TaskExecutor interface.
2. The TaskExecutor will accept and execute implementations of the provided Task interface.
3. The TaskExecutor and Task interface must implement the interface given in the source file including package and exact method signatures i.e. no changes are allowed.
4. Each thread will be assigned a unique name when created. See Thread.setName(String).
5. Threads will be maintained in a pool and reused to execute a Task. Threads should not be created and destroyed for each taskís execution.
6. Tasks will execute concurrently on N threads where N is the thread pool size and is provided as a service initialization parameter.
7. When the number of tasks exceeds the number of threads, unexecuted tasks will remain on the FIFO until removed by a thread.
8. Every threadís execution must block when the FIFO is empty i.e. Threads should not spin or busy-wait when attempting to obtain a task from the serviceís empty FIFO.
9. The project will be delivered as a library jar file which will be linked with the test applications used to initialize and test the TaskExecutorís correct implementation.
10. The TaskExecutor should catch, report (log), and eat any exceptions thrown during an application-specific Taskís execution.

Task executor implementation constructor??

Attached File(s)

Is This A Good Question/Topic? 0
  • +

Replies To: TaskExecutor is a service that accepts instances of Tasks

#2 CasiOo   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1577
  • View blog
  • Posts: 3,551
  • Joined: 05-April 11

Re: TaskExecutor is a service that accepts instances of Tasks

Posted 06 July 2014 - 01:55 PM

Post any relevant code between [ code][/code] tags (without the space)
Most of us won't download your attachment :)

And what is your question? We won't code it all for you
Was This Post Helpful? 0
  • +
  • -

#3 g00se   User is online

  • D.I.C Lover
  • member icon

Reputation: 3580
  • View blog
  • Posts: 16,354
  • Joined: 20-September 08

Re: TaskExecutor is a service that accepts instances of Tasks

Posted 06 July 2014 - 01:57 PM

What is your question ??
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1