• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

OCP book's concept about scheduleAtFixedRate() method

 
Ranch Hand
Posts: 80
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. I'm studying for ocp8 exam from OCP study guide of jeanne and scott chapter 7 about Concurrency.

I'm gonna transcribe what the books says:
Given: service.scheduleAtFixedRate(command, 5, 1, TimeUnit.MINUTES);
This  example executes a Runnable task every minute, following an initial five-minute delay

One risk of using this method is the possibility a task could consistently take longer to run than the period between tasks.


Up to here what I understand is that for example in this case on the first minute a task is created and submitted and then it's gonna take 5 minutes to be executed. And in the minute number two ( while the first task is on delaying) another task is submitted and so on.

What would happen if the task consistently took five minutes to execute?



Despite the fact that the task is still running, the ScheduledExecutorService would submit a new task to be started every minute.



-> And now what I'm not understandying:

If a single thread executor was used, over time this would result in endless set tasks being scheduled, which would run back to back assuming that no other tasks were submitted to the ScheduledExecutorService.



Especially I can't totally undertand the following: "this would result in endless set tasks being scheduled, which would run back to back assuming that no other tasks were submitted"

I can guess that a stack of tasks would be piled up as if there was not every minute a new task being submitted.


Thanks!
 
author & internet detective
Posts: 39675
785
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right. It's like I give you a piece of paper to hold. And I say that I will come by to get the papers one at a time, but every time I will leave you with 5 new papers. So every time I show up you have more and more to hold. But you never get any closer to being done because I drop off more than I retrieve.
 
Pablo Napoli
Ranch Hand
Posts: 80
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne!. Your example was very graphic.

By the way, because of personal motives I will have to move the date of my exam for later. I was expecting take it on December but I think it will be on March or April. So my question is when do you think OCP 8 will be removed by Oracle. Or if in other cases they did let people known with anticipation.

Thanks so much!
 
Marshal
Posts: 66639
251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pablo Napoli wrote:. . . when do you think OCP 8 will be removed by Oracle. . . .

Don't know. Have you looked on the Oracle exams website? Last time they removed any exams, for Java6/7, they gave lots of notice, I think over 1½ years, so I think you still have a long time to sit a Java8 exam.
 
Jeanne Boyarsky
author & internet detective
Posts: 39675
785
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java 6 and 7 exams were retired last year. And they gave a ton of notice.

Pablo: Nothing to worry about. I would be shocked if the Java 8 exam went away in 2020
 
Pablo Napoli
Ranch Hand
Posts: 80
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both for your attention! I whish next year take that exam and later I'd like get your new book ocp 11 to take, maybe on 2021, the other one.

Without your books I coulnd't have taken the OCA.

Cheers!, Pablo.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!