Results 1 to 5 of 5
  1. #1
    rameshkr is offline Member
    Join Date
    Sep 2008
    Posts
    2
    Rep Power
    0

    Default how high-priority thread allow other thread

    What must a high-priority thread do when it needs to perform a critical operation once every five seconds, but which still allows other threads to get CPU time?
    Choice 1
    Reduce its priority using the setPriority() method.
    Choice 2
    Use the Thread.sleep() method to relinquish control of the CPU.
    Choice 3
    Add all the other threads into its own ThreadGroup.
    Choice 4
    Use the notifyAll() method to increase priority of other threads.
    Choice 5
    Put its critical code in a Timer object.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Have you written a test program to see what happens?

  3. #3
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Suggestion given by Norm is the best one.
    Write a simple program with 4-5 simple threads, implement all your ways and check which would best suite.

    I prefer choice2, not sure check it out.
    To finish sooner, take your own time....
    Nivedithaaaa

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Timer object probably best, but as the other two posts suggest, only testing show true result.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. passing a value from parent thread to child thread
    By sachinj13 in forum Threads and Synchronization
    Replies: 7
    Last Post: 09-07-2008, 09:06 PM
  2. data from the main/GUI thread to another runnin thread...
    By cornercuttin in forum Threads and Synchronization
    Replies: 2
    Last Post: 04-23-2008, 10:30 PM
  3. How to get/set thread priority
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 06:40 PM
  4. Replies: 0
    Last Post: 01-28-2008, 07:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •