1.
What is deadlock ?
when two or more threads waiting for each other to release lock and get stuck for infinite time , situation is called deadlock . it will only happen in case of multitasking.
2.
how to detect deadlock ?
simplest way :
1). under linux: kill -3
this will print status of all the thread in application log file and you can see which thread is locked on which object
2). via jconsole:
jconsole will show you exactly which threads are get locked and on which object
3. Why we call start() method which in turns calls run() method, why not we directly call run() method ?
when you call start() method it creates new Thread and execute code declared in run() while directly calling run() method doesn’t create any new thread and execute code on same calling thread
4. Why do we need Synchronization in Java?
1) synchronized keyword in java provides locking which ensures mutual exclusive access of shared resource and prevent data race.
2) synchronized keyword also prevent reordering of code statement by compiler which can cause subtle concurrent issue if we don't use synchronized or volatile keyword.
3) synchronized keyword involve locking and unlocking. before entering into synchronized method or block thread needs to acquire the lock at this point it reads data from main memory than cache and when it release the lock it flushes write operation into main memory which eliminates memory inconsistency errors.
分享到:
相关推荐
7)....Added: Streaming unpacked debug info into temporal files instead of memory - this greatly reduces run-time application memory usage at cost of slightly slower exception processing. This also ...
- **Unchecked Exceptions and Threads:** In Java, if an unchecked exception is thrown by a thread, it does not cause the program to terminate immediately but rather propagates up the call stack until ...
- **题目**: When Resource Allocation Graph contains a cycle, it will have a deadlock. - **解析**: 错误。资源分配图中含有环并不一定意味着系统处于死锁状态。只有当环中的所有进程都持有资源且等待其他进程...
However, this approach can limit the efficiency and responsiveness of applications, especially in today's multi-core processors. Multithreading models introduce the idea of having multiple threads ...
Byte 4-7: ObjectID – 0x 75D7831F (1977058079) Byte 8-9: IndexID – 0x0001 Byte 10-16: Hash Key value – 0x 02014F0BEC4E For more information about how to decode this value, see also… Inside ...
* Multi-thread:多线程,指计算机程序中多个线程之间的并发执行机制。 三、计算机网络相关知识点 * Router:路由器,指计算机网络中连接多个网络的设备。 * Remote:远程,指计算机网络中的一种远程访问技术。 * ...
Process Deadlock 进程死锁是指两个或两个以上的进程在执行过程中因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下一步。通常情况下,死锁的发生需要满足四个必要条件:互斥条件、请求与...
Debugging: Threadview now updates when single stepping and cnanges made there will affect the currently debugged thread (before it didn't) Debugging: Added Code Filter. This lets you filter out code ...
在编程领域,多线程(Multi-Threading)是一种强大的技术,允许程序同时执行多个任务,以提高效率和响应性。在“sample console multithreading”这个项目中,我们将深入探讨如何利用多线程在控制台应用程序...
【标签】"Multi TheadDemo Thead 线程" 提到了"Multi",意味着这个示例可能涉及到多线程的高级特性,如线程池、守护线程(Daemon Thread)、线程优先级、中断线程、线程组等。线程池(ThreadPool)是一种有效管理...