Java Questions

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

1) What is fail-fast property? At high level - Fail-fast is a property of a system or software with respect to its response to failures.

A fail-fast system is designed to immediately report any failure or condition that is likely to lead to failure. Fail-fast systems are usually designed to stop normal operation rather than attempt to continue a possibly-flawed process. When a problem occurs, a fail-fast system fails immediately and visibly. Failing fast is a non-intuitive technique: "failing immediately and visibly" sounds like it would make your software more fragile, but it actually makes it more robust. Bugs are easier to find and fix, so fewer go into production. In Java, Fail-fast term can be related to context of iterators. If an iterator has been created on a collection object and some other thread tries to modify the collection object "structurally", a concurrent modification exception will be thrown. It is possible for other threads though to invoke "set" method since it doesn't modify the collection "structurally". However, if prior to calling "set", the collection has been modified structurally, "IllegalArgumentException" will be thrown.

2) What is difference between thread and process? 1. Threads share the address space of the process that created it; processes have their own address. 2. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. 3. Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with sibling processes. 4. Threads have almost no overhead; processes have considerable overhead. 5. New threads are easily created; new processes require duplication of the parent process. 6. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. 7. Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process; changes to the parent process do not affect child processes.

You might also like