• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

sheduling problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have written a job shedular
it has two queues one directly submiitng the job another time shedular as time is set it sends the job to the queue

my queue class

here is the class i add job to shedular which in turn adds the job to queue at sheduled time

my question is in the shedulequeue class why i need to
create instance of queueimpl .. when i check at this point if thread is alive it showing the thread is alive ?

thanks in advance
[ April 23, 2005: Message edited by: Jim Yingst ]
 
manojdesai sompadi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i missed to mention i started queue in
SheduleAction with queim.start() after adding job .
but i have to start the queue again in shedulequeue with new insatance of the queimpl ?when i started the thread once in sheduleaction ..why i need to start it again in shedulequeue class ?
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have an indirect setup here. You are using a Timer (which is a task scheduler), but you are not running the tasks directly. Instead, all you do is place the real tasks onto a queue which is then run by the queueimpl class in another thread.

The reason you need the queueimpl, is because all you timer thread does is place the job onto the queue for the queue impl. It does nothing else.

Henry
 
Henry Wong
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manojdesai sompadi:
sorry i missed to mention i started queue in
SheduleAction with queim.start() after adding job .
but i have to start the queue again in shedulequeue with new insatance of the queimpl ?when i started the thread once in sheduleaction ..why i need to start it again in shedulequeue class ?



Okay, I don't have enough code for this. In any case, could you use "code" tags. It is very difficult to read.

Thanks,
Henry
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added [code] tags to the first post. Manojdesai, please use these in the future to make code readable by preserving the indentation.
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing I noticed is that you're using static members in places that don't seem correct:
  • Queue.queue
  • SheduleQueue.queuelist

  • Should those be instance members?
     
    manojdesai sompadi
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    } catch (Exception e) {

    // Report the error using the appropriate name and ID.
    errors.add("name", new ActionError("id"));

    }

    // If a message is required, save the specified key(s)
    // into the request for use by the <struts:errors> tag.

    if (!errors.isEmpty()) {
    saveErrors(request, errors);

    // Forward control to the appropriate 'failure' URI (change name as desired)
    //forward = mapping.findForward("failure");

    } else {

    // Forward control to the appropriate 'success' URI (change name as desired)
    // forward = mapping.findForward("success");

    }

    // Finish with
    return mapping.findForward("success");

    }
    }




    here is my sheduler
    public class SheduleQueue {
    static LinkedList queuelist = new LinkedList();
    queue que = new queue();
    // timer

    int delay = 5000; // delay for 5 sec.
    int period = 1000; // repeat every sec.
    Timer timer = new Timer();





    BuildStatusAction statusform = new BuildStatusAction();
    // Add Build to the build queue
    public synchronized void addBuild(Object key ,Object value) {

    queuelist.addLast(o);

    }

    // Retrieve build from the build queue; block if the queue is empty
    public synchronized void addsheduledjob() throws InterruptedException {

    timer.schedule( new TimerTask() {
    public void run() {
    // Task here ...
    // here i have to create instance of Queue and
    // QueueImpl else the jobs are being added to queue but are //not being executed
    // Queue addtoqueue = new Queue();
    // QueueImpl queim = new QueueImpl(addtoqueue);
    //queim.start();
    // add job to queueat sheduled time
    que.addBuild("job");

    }
    }, delay);
    // delete the value from list once it is added to queue
    }




    }[/code]
    sorry i was not aware of code tags earlier i added them now .
    thanks for the responces
    in shdeuleaction class i started the thread of QueueImpl class .when i am adding jobs from sheduleQueue to this que ..then the current thread suppose to take the job in the que but the jobs are remaining in queue with out run by QueueImpl ..i have to start the thread again in the shedule Queue ?
     
    Jim Yingst
    Wanderer
    Posts: 18671
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Manojdesai - it looks like you're nesting code tags within other code tags, which doesn't work (as you can see above). You can edit your own posts after you make them. Just look for the little pencil-and-paper icon along the top edge of your post. Then you can fix the code tags to display like you want them to. I recommend using several separate pairs of code tags, since you have several different seciont of code, separated by sentences which are not code.

    This way, text which is not code stands out from the code, and is more readable.

    See?
    [ April 24, 2005: Message edited by: Jim Yingst ]
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic