Results 1 to 13 of 13

Thread: What is a deadlock in java ?

  1. #1

  2. #2
    Registered pxljobs's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    290
    Deadlock in java is a programming situation where two or more threads blocked waiting for other blocked waiting thread to finish and thus none of the threads will ever complete example thread A,thread B these two threads are in deadlock state thread A waiting for thread B to finish,thread B waiting for thread A to finish so this process is known as deadlock.

  3. #3
    Thoughtgrid Thoughtgrid's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    219
    It is an situation more than two threads block forever waiting for same resources at same time you can use some technique to avoid the deadlock these are non overlapping lock,lock ordering,lock timeout,single thread these are some technique used to prevent the deadlock.

  4. #4
    Deadlock describes a situation where two or more threads are blocked forever, waiting for each other.

  5. #5
    Registered
    Join Date
    Nov 2016
    Posts
    649
    Deadlock can occur in a situation when a thread is waiting for an object lock, that is acquired by another thread and second thread is waiting for an object lock that is acquired by first thread. Since, both threads are waiting for each other to release the lock, the condition is called deadlock.

  6. #6

  7. #7
    Registered
    Join Date
    Feb 2017
    Posts
    10
    Hi, Deadlock situation may be likened to two people who are drawing diagrams, with only one pencil and one ruler between them. If one person takes the pencil and the other takes the ruler, a deadlock occurs when the person with the pencil needs the ruler and the person with the ruler needs the pencil to finish his work with the ruler. Both requests can't be satisfied, so a deadlock occurs.

    Good luck!

    ______
    best static code analysis tools

  8. #8
    Junior Registered
    Join Date
    Dec 2016
    Posts
    8
    Deadlock describes a situation where two or more threads are blocked forever, waiting for each other. Deadlock occurs when multiple threads need the same locks but obtain them in different order. It mainly occur because of lock acquisition in wrong order. programmers tries to avoid deadlock but it happens due to programming errors.

  9. #9
    Registered
    Join Date
    Jan 2017
    Posts
    55
    Deadlock describes a situation where two or more threads are blocked forever, waiting for each other. ... A Java multithreaded program may suffer from the deadlock condition because the synchronized keyword causes the executing thread to block while waiting for the lock, or monitor, associated with the specified object.

    Thank you~!

  10. #10
    Office Space for rent
    Join Date
    Mar 2017
    Location
    Bangalore
    Posts
    45
    In Java Deadlock is an situation in which a thread is waiting for the object lock that is hold by another thread and that another is waiting for the object lock which is hold by the first thread.

  11. #11
    Junior Registered
    Join Date
    Jul 2017
    Posts
    1
    A lock occurs when multiple processes try to access the same resource at the same time. A deadlock occurs when the waiting process is still holding on to another resource that the first needs before it can finish.

    Deadlock condition

    Resource1 and resource2 are used by Thread1 and Thread2

    Thread1 starts to use Resource1
    Thread1 and Thread2 try to start using resource2
    Thread2 'wins' and gets resource2 first
    now Thread2 needs to use Resource1
    Resource1 is already locked by Thread1, which is waiting for Thread2

    The above situation create deadlock because :

    Thread 1 locks Resource1, waits for resource2
    Thread 2 locks resource2, waits for Resource1

    More on...deadlock in Java

    Dell

  12. #12
    Registered
    Join Date
    Nov 2017
    Location
    Sao Paulo
    Posts
    159
    Deadlock can occur in a situation when a thread is waiting for an object lock, that is acquired by another thread and second thread is waiting for an object lock that is acquired by first thread. Since, both threads are waiting for each other to release the lock, the condition is called deadlock.

  13. #13
    Registered
    Join Date
    Oct 2016
    Posts
    270
    A deadlock is a state where two, or more, threads are blocked waiting (Java Doc) for the other blocked waiting thread (or threads) to finish and thus none of the threads will ever complete. For example, say we have two threads called thread-A and thread-B. These threads are in a deadlock state if thread-A is waiting for thread-B to finish, while thread-B is waiting for thread-A to finish as shown in the following image. Once in deadlock state, both threads will hang forever.
    Best Android Training | Devops Training | SQL Server Training and many more IT courses.

Similar Threads

  1. what is Exception in java ?
    By penrix in forum Website Programming & Databases
    Replies: 9
    Last Post: 01-09-2018, 05:15 AM
  2. What is System.out in Java?
    By penrix in forum HTML, CSS, Layout, and Design
    Replies: 10
    Last Post: 07-06-2017, 02:07 AM
  3. looking for java vps
    By Paul-Henri in forum Web Hosting & Servers
    Replies: 4
    Last Post: 12-30-2015, 04:57 AM
  4. java help
    By VietBoyVS in forum Website Programming & Databases
    Replies: 3
    Last Post: 05-01-2004, 12:49 PM
  5. Java Script
    By Browneyes105 in forum HTML, CSS, Layout, and Design
    Replies: 8
    Last Post: 01-22-2004, 05:18 AM

Tags for this Thread

Bookmarks

Posting Permissions

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