This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • 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...
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • 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
 
Henry Wong
author
Sheriff
Posts: 22850
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 22850
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 22850
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!