• 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

Concurrency question

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is question for java OCP Boyarsky concurrent chapter
What I don't understand is that forEach method takes a consumer bun inside service.submit takes runable and returns a Future object. So I'm slightly confused as to what is going on .Code compiles correctly but I don't know why.

16.  What is the result of executing the following application? (Choose all that apply.)

 
Rancher
Posts: 261
12
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I asked the very same question yesterday: see here  
 
Brecht Geeraerts
Rancher
Posts: 261
12
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a side note: Notice that your code is displayed on one single line. This makes it next to impossible for readers (e.g. those who do not have the book) to understand the code snippet.  
 
manishkhu khurana
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Brecht , I am new here so learning the ropes regarding code pasting , I copied and pressed "code" button not sure how it came out like this .
 
Brecht Geeraerts
Rancher
Posts: 261
12
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No worries, just add a line break by pressing enter wherever you need one. As long as the code is within the code tags, it will still be part of the code block.

What I do whenever I want to post a message with url links, code tags etc I use the preview button. That way I can see how my code will appear once I click submit.

Welcome to the Ranch, by the way. I'm sure you will enjoy your stay here.  
 
reply
    Bookmark Topic Watch Topic
  • New Topic