Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multitasking and Threads

 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cam across following question about threads in Marcus site:
Are threads equivalent to multi-tasking?
a) True
b) False

According to me the answer should be a) but the answer is false.
Can anybody explain why? Any help will be appreciated.

Regards
Abhijit
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you find this question? I always try to give a reasonably detailed explanation of the thought behind my questions.
 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marcus,
Extremly sorry for the miscommunication. The question was from some other mock test.
 
Chandrahas Tore
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhijit,

To answer this question you first need to know what is multitasking. It means a multiple tasks can be runned in a single process/program. It's different from multiprogrammimg. To achieve multitasking a process creates multiple threads. These threads then do a particular job/task. So at a time a thread can do a single task. Hence threads are not multitasking.

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



To answer this question you first need to know what is multitasking. It means a multiple tasks can be runned in a single process/program. It's different from multiprogrammimg. To achieve multitasking a process creates multiple threads. These threads then do a particular job/task. So at a time a thread can do a single task. Hence threads are not multitasking.






Surmise:

Threads can be used for implementing multi tasking ..?

 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the reasons I asked was that it did look very much like a version of a question I used to have. I think I changed the text to read "is the same as" rather than equivalent to. The problem is that I have about 800 odd questions in various pages and databases and it gets hard to trace them. Of course I often see question "by other people" that look very very similar to mine. This is why some of my questions have some very odd variable names in them that match up to various people, places, cats, dogs I have known ....

But to give an analogy that illustrates the point behind the question.

Windows 3.x supported multi tasking but not multi threading. You could have multiple tasks or programs running but it did not support multiple paths of execution within one program. This was one of the reasons why it would have been very difficult to port Java to windows 3.x. I don't think you will get that type of overall conceptual question on the exam, but if you understand that concept then you will be more likely to understand the questions that do come up.

One other important feature of threading vs multi tasking is that threads can directly share data whereas multiple executing programs do not directly have access to each others data.

The SCJP exam does like to test you knowlege of Threading, and it is a fairly difficult topic so write plenty of practice code. Note that some Thread behaviour is "non deterministic", meaning you cannot know for certain what will happen, even if the same sequence of events run on 100 times on your machine it might not give the same result on attempt 101. So this is one area where it is very, very important to understand the ideas behind the code.

Marcus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic