Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ExecutorService with 1 thread  RSS feed

 
Jim Bob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

Can someone answer me this question: If I create an ExecutorService like so:

ExecutorService myService = Executors.newFixedThreadPool(1);

and then call(pseudocode):

myService.submit(sometask1);
myService.submit(sometask2);

Is it guaranteed that seeing as the ExecutorService only has one thread (see constructor above), is it guaranteed that sometask2 will only execute after sometask1 has finished?

In other words, with a pool size of 1, sometask1 and sometask2 will never execute concurrently in this situation??

thanks a lot.
 
Jim Bob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No probs....done!

- Jim.
 
Scott Selikoff
author
Bartender
Posts: 4081
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Jim Bob"

Please re-read the section on 'obviously fictitious names' and change your name appropriately.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Executor interface JavaDoc includes a sample Executor that runs one task at a time, if that's your objective.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!