What is Starvation? What is a Livelock?

Starvation and livelock are much less common a problem than deadlock, but are still problems that every designer of concurrent software is likely to encounter.LiveLockLivelock occurs when all threads are blocked, or are otherwise unable to proceed due to unavailability of required resources, and the non-existence of any unblocked thread to make those resources available. In terms of Java API, thread livelock can occur in following conditions:When all the threads in a program execute Object.wait(0) on an object with zero parameter. The program is...

What is the difference between sleep(), suspend() and wait()?

Ans:Thread.sleep() sends the current thread into the "Not Runnable" state for some amount of time. The thread keeps the monitors it has aquired -- i.e. if the thread is currently in a synchronized block or method no other thread can enter this block or method. If another thread calls t.interrupt() it will wake up the sleeping thread. Note that sleep is a static method, which means that it always affects the current thread (the one that is executing the sleep method). A common mistake is to call t.sleep() where t is a different thread; even then,...

What is ThreadLocal class? How can it be used?

Ans:Below are some key points about ThreadLocal variablesA thread-local variable effectively provides a separate copy of its value for each thread that uses it.ThreadLocal instances are typically private static fields in classes that wish to associate state with a threadIn case when multiple threads access a ThreadLocal instance, separate copy of Threadlocal variable is maintained for each thread.Common use is seen in DAO pattern where the DAO class can be singleton but the Database connection can be maintained separately for each thread. (Per...

Folder Option Not Visible In Tools Menu

Want to change your windows folder options such as Show hidden files or Hide extensions for know file types.But my folder options is not visible. How to make folder options visible under tools menu. Here is the solution: Step 1 : Goto Start Menu and Select Run otpion. Step 2 : Type gpedit.msc in run dialog box. Group Policy dialog box will be displayed. Step 3 : In Group Policy dialog box in the left pane selectuser configuration->administrative templates->windows components->windows...

How do Java threads make the environment asynchrnous?

Ans: The thread mechanism in Java begins with the main entry point thread the runtime environment creates to start a Java program. When you use that initial thread create secondary threads, each one runs independently of the other. The Java virtual machine manages the execution of the threads so they behave as if they all run at the same time, in fact each thread briefly takes turns at execution. In its simplest form there may be no communication or synchronization between multiple threads in a Java program and they each run to completion independently...

Power On Your Computer With Mouse

Want to power on your computer? Press Power Button on cabinet. Is there any other way? Yah... Double Click with your mouse. But for that you need to make some settings. Here goes the settings. Step 1 Restart your computer. Step 2 Press DEL button (F2 in some motherboards) to goto the BIOS settings. Step 3 Select Integrated Peripherals from main menu. Step 4 If PS/2 mouse power on disabled, activate it by press page up/ page down key it will became Double-Click. Step 5 Press Esc key to exit. Step 6 Press F10 to save and...

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More