• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Comparison between Threads-based scheduling and Timer-based scheduling in Java Thread

 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the book compare the pros and cons between Threads-based scheduling and Timer-based scheduling... We have discussed this issue in the last week too... That thread can be reached here. I just would like to know whether the book discusses this issue in details or not... Thanks...
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot see a list of pro and cons on Threads-based scheduling and Timer-based scheduling. Maybe an usage guide would be more appropriate, but I think you can decide dependent on your application goal.

./pope
 
author
Posts: 23951
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 Ko Ko Naing:
Does the book compare the pros and cons between Threads-based scheduling and Timer-based scheduling... We have discussed this issue in the last week too... I just would like to know whether the book discusses this issue in details or not... Thanks...



Hmmm... interesting question. I am not sure if I have an answer... The early chapters used a separate thread to implement many of the examples. Later, during our discussion of task scheduling, the two JDK 1.3 timers and the JDK 1.5 task scheduler, we rewrite some of the examples to use them. We do talk about the differences, and the advantages of using them, but we don't do a pro/con comparision of which is best.

Henry
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:
Later, during our discussion of task scheduling, the two JDK 1.3 timers and the JDK 1.5 task scheduler, we rewrite some of the examples to use them. We do talk about the differences, and the advantages of using them, but we don't do a pro/con comparision of which is best.


Could you explain a bit about JDK 1.5 task scheduler? Just an introductory explanation about it is alright...

Thanks a lot for explaining the book contents related to those two mechanisms...
 
Henry Wong
author
Posts: 23951
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 Ko Ko Naing:

Could you explain a bit about JDK 1.5 task scheduler? Just an introductory explanation about it is alright...

Thanks a lot for explaining the book contents related to those two mechanisms...



You welcome... glad to be of service...

As for the JDK 1.5 task executor... If you have used the timer classes before, it is pretty much the same functionality -- just a ton more options. Also, the executor is ...

First, it is also a thread pool, meaning some of the many options is to adjust the size, queue, and policies of how the tasks are to be executed.

Second, it takes both runnable and callables. The runnable is the interface that we all know and use for threads. The callable is like a runnable, except that it supports a return types and exceptions. This is necessary, if your task returns values and/or throw exceptions.

Henry
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:

Second, it takes both runnable and callables. The runnable is the interface that we all know and use for threads. The callable is like a runnable, except that it supports a return types and exceptions. This is necessary, if your task returns values and/or throw exceptions.



Oh, do u mean that JDK 1.5 task executor can be used from both runnable and callable interfaces, where Threads can be used from runnable interface only?

I have explored other JDK 1.5's new features like generics and foreach looping, but I've not touched its task executor feature yet... I do thank you for your great explanation on it...
 
Henry Wong
author
Posts: 23951
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 Ko Ko Naing:

Oh, do u mean that JDK 1.5 task executor can be used from both runnable and callable interfaces, where Threads can be used from runnable interface only?



Yes, you have the option to use either the runnable or callable interface in your tasks. In fact, some tasks can be runnable, while other tasks can be callables, using the same executor.

Henry
 
All of the following truths are shameless lies. But what about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic