• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Threads Question

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have confusion with this particular question on Marcus Green Exam.

Which of the statements are true? Select two.

1. The idea of threading is same as multitasking
2. No two threads can access the same variables
3. using synchronization within a thread may cause performance penalties.
4. the use of threads may make the exact path of execution unpredictable.

now the answer is 3 & 4.

is 1 also not the right answer?

Thanks
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The definition of multitask is: The concurrent operation by one central processing unit of two or more processes.


If you consider all threads to belong to the same process- it is not multitasking. However, I would normally consider different threads to be engaging in different processes.

It is semantic: is a process an entire application, or a thread? From the answer given on the answer key, they are interpreting a process to be a separate application, and not different threads.

I disagree with this answer and hope nothing like that (semantic interpretation of vague english words) are on the real test.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me, multitasking implies processes working in separate memory spaces - ie separate programs. Java Threads all work in the same JVM memory space.
Bill
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
4. the use of threads may make the exact path of execution unpredictable.

threads can make the path of execution unpredictable? how come? an execution is a top-down approach, meaning from line 1 to line 2 to line 3 and so forth. it can be interrupted but execution goes to the next line. please help.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doyle, I think the point is that execution may go from line 4 in thread A to line 10 in thread B. Within a single thread the path of execution is still predictable, but the order of execution across threads is unpredictable in the sense that you don't get any guarantees about it.

This unpredictability does imply that if you don't carefully control the interaction between threads, the behaviour of your entire application becomes unpredictable. This, of course, is the whole issue of thread safety.

- Peter
 
Doyle Matt
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peter. Now I can sleep tonight w/o thinking of why and how it is about threads. Many Thanks again.
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic