• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Threads  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the following true or false?
1. Current thread suspends when a file is opened for reading.
2. A thread can stop execution if it was performing an I/O task with a remote file.
3. It is possible to suspend a thread indefinitely.
Thanks.
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are your guesses and why? (Just out of curiosity, which book are you using to prepare for Certification?)
 
Frank Tollenaar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gone through "Sam's Teach Yourself Java in 21 Days", R&H's "Java 2 Cert. Study Guide", and Brogden's "Exam Cram".
1. I think true.
2. I have no idea.
3. I think true because if a thread is suspended and resume() is never called, the thread could be indefinately suspended.
[This message has been edited by maha anna (edited July 22, 2000).]
 
Tony Alicea
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In standard "normal" programming, I/O operations take a significant amount of time when compared to the speed at which the CPU executes instructions. The reasons are simple: in general, traditional I/O devices are simply slow. Imagine a hard drive. It has to spin, the head has to position itself, search, access in short (or should I say long) it takes forever to complete an I/O operation.
In some operating systems (OS) using assembly language or C/C++, one has multiple choices on what to do with the thread that requests I/O. You can have the thread sit an wait and do nothing until the operation is complete. You can ask the OS to start the I/O while the thread continues and ask it to interrupt you when the I/O is complete. Or you can continue and have the OS insert an entry in the thread's "to do" list (AKA task queue) when the I/O completes so that the thread can check for I/O completion later at its leisure.
In Java (last time I looked), all I/O makes the thread wait for I/O completion. That is called "blocking".
Notice that there is no difference between 1 and 2 because in most (all?) OS, opening (versus reading) a file requires some I/O. The fact that it is a "remote" file makes no difference. In fact it may have to wait longer. But wait it will.
And you are correct about (3).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!