Click here to close now.


Java IoT Authors: John Grimm, Pat Romanski, Elizabeth White, Carmen Gonzalez, Brian Daleiden

Related Topics: Java IoT, Weblogic, Containers Expo Blog, Recurring Revenue

Java IoT: Article

Dealing with Application Deadlocks

Detecting and reporting deadlocks with the WebLogic Server

A deadlock is a situation where two or more threads are blocked while waiting to obtain locks that some of the other threads in the deadlock are holding. Deadlocks can occur when multiple threads need the same locks, at the same time, but obtain them in different order. For instance, if thread 1 locks A, and tries to lock B, and thread 2 has already locked B, and tries to lock A, a deadlock arises. Thread 1 can never get B, and thread 2 can never get A. In addition, neither of them will ever know. They will remain blocked on each of their objects, A and B, forever.

Deadlock Detection
The most common way of detecting whether your application is deadlocked is by analyzing thread dumps of the Java Virtual Machine while its in the state of appearing hung. A thread dump is a snapshot of the virtual machine's current state, including stack traces for each Java thread.

The thread dump outputs the state of each thread, which may be one of the following:

  • NEW: This state represents a new thread that is not yet started.
  • RUNNABLE: This state represents a thread that is executing in the underlying JVM. Here executing in the JVM doesn't mean that the thread is always executing in the OS as well - it may wait for a resource from the operating system like the processor while being in this state.
  • BLOCKED: This state represents a thread that has been blocked and is waiting for a moniotor to enter/re-enter a synchronized block/method. A thread gets into this state after calling the Object.wait method.
  • WAITING: This state represnts a thread in the waiting state. This wait is over only when some other thread performs some appropriate action. A thread can get into this state either by calling - Object.wait (without timeout), Thread.join (without timeout), or LockSupport.park methods.
  • TIMED_WAITING: This state represents a thread that is required to wait at max for a specified time limit. A thread can get into this state by calling any of these methods: Thread.sleep, Object.wait (with timeout specified), Thread.join (with timeout specified), LockSupport.parkNanos, and LockSupport.parkUntil
  • TERMINATED: This state reprents a thread that has completed its execution either by returning from the run() method after completing the execution OR by throwing an exception that propagated from the run() method and hence caused the termination of the thread.

A thread that appears as "java.lang.Thread.State: BLOCKED (on object monitor)" in the stacktrace indicates that it's waiting to enter a synchronized block and acquire a Java monitor. Alternatively, the code may call an Object.wait method every time the lock is not acquired, causing the threads to appear as "java.lang.Thread.State: WAITING" in the stacktrace.

A deadlock is detected if a complete circle of such thrads can be seen in the thread dump where two or more threads are blocked/waiting, with each blocked/waiting thread waiting to acquire a lock on an object that has been locked by another blocked/waiting thread.

Example :

"Thread-1" prio=6 tid=0x02a99c00 nid=0xee0 waiting for monitor entr...
java.lang.Thread.State: BLOCKED (on object monitor)
at SimpleDeadLock$
- waiting to lock <0x229bd238> (a java.lang.Object)
- locked <0x229bd240> (a java.lang.Object)

"Thread-0" prio=6 tid=0x02a99000 nid=0xefc waiting for monitor entr...
java.lang.Thread.State: BLOCKED (on object monitor)
at SimpleDeadLock$
- waiting to lock <0x229bd240> (a java.lang.Object)
- locked <0x229bd238> (a java.lang.Object)

In the above thread dump, it can be seen that "Thread-0" and "Thread-1" are in a "BLOCKED" state. "Thread-0" holds a lock on object "0x229bd238" and is waiting to acquire a lock on object "0x229bd240", while at the same time "Thread-1" holds a lock on object "0x229bd240" and is waiting to acquire a lock on object "0x229bd238". Since each of the threads has acquired a lock on an object that the other thread needs in order to complete its operation, they will wait in the same state infinitely, causing the application to hang.

Acquiring Thread Dumps
A thread dump of a running JVM may be taken in various ways, a few of the methods are listed below:

  • by sending a SIGQUIT signal to the JVM

kill -3 pid > threadDumpFilename 2>&1

  • by using WebLogic scripting tool
    export JAVA_HOME=<java home>
    export WL_HOME=<WebLogic home>

    cd WL_HOME/server/bin
    . ./
    java WebLogic.WLST

    cd ('Servers')
    cd ('<server name>')


  • by using WebLogic.Admin utility (deprecated)
    export JAVA_HOME=<java home>
    export WL_HOME=<WebLogic home>

    cd WL_HOME/server/bin
    . ./

java WebLogic.Admin <url>:<port> -username <username> -password <password> THREAD_DUMP

  • by using WebLogic admin console

Login to AdminConsole->Server -> Monitoring -> Threads

  • by using Jrockit command line utility (Jrockit JVM)
    export JAVA_HOME=<java home>
    export WL_HOME=<WebLogic home>

    cd WL_HOME/server/bin
    . ./

jrcmd <pid> print_threads

· by using the Jstack utility (HotSpot JVM)
export JAVA_HOME=<java home>
export WL_HOME=<WebLogic home>

cd WL_HOME/server/bin
. ./

jstack <pid>

More Stories By Sanat Vij

Sanat Vij is a professional software engineer currently working at CenturyLink. He has vast experience in developing high availability applications, configuring application servers, JVM profiling and memory management. He specializes in performance tuning of applications, reducing response times, and increasing stability.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

@ThingsExpo Stories
The Internet of Things (IoT) is growing rapidly by extending current technologies, products and networks. By 2020, Cisco estimates there will be 50 billion connected devices. Gartner has forecast revenues of over $300 billion, just to IoT suppliers. Now is the time to figure out how you’ll make money – not just create innovative products. With hundreds of new products and companies jumping into the IoT fray every month, there’s no shortage of innovation. Despite this, McKinsey/VisionMobile data shows "less than 10 percent of IoT developers are making enough to support a reasonably sized team....
Internet of @ThingsExpo, taking place June 7-9, 2016 at Javits Center, New York City and Nov 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with the 18th International @CloudExpo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world and ThingsExpo New York Call for Papers is now open.
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo 2016 in New York and Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound cha...
Just over a week ago I received a long and loud sustained applause for a presentation I delivered at this year’s Cloud Expo in Santa Clara. I was extremely pleased with the turnout and had some very good conversations with many of the attendees. Over the next few days I had many more meaningful conversations and was not only happy with the results but also learned a few new things. Here is everything I learned in those three days distilled into three short points.
DevOps is about increasing efficiency, but nothing is more inefficient than building the same application twice. However, this is a routine occurrence with enterprise applications that need both a rich desktop web interface and strong mobile support. With recent technological advances from Isomorphic Software and others, rich desktop and tuned mobile experiences can now be created with a single codebase – without compromising functionality, performance or usability. In his session at DevOps Summit, Charles Kendrick, CTO and Chief Architect at Isomorphic Software, demonstrated examples of com...
As organizations realize the scope of the Internet of Things, gaining key insights from Big Data, through the use of advanced analytics, becomes crucial. However, IoT also creates the need for petabyte scale storage of data from millions of devices. A new type of Storage is required which seamlessly integrates robust data analytics with massive scale. These storage systems will act as “smart systems” provide in-place analytics that speed discovery and enable businesses to quickly derive meaningful and actionable insights. In his session at @ThingsExpo, Paul Turner, Chief Marketing Officer at...
In his keynote at @ThingsExpo, Chris Matthieu, Director of IoT Engineering at Citrix and co-founder and CTO of Octoblu, focused on building an IoT platform and company. He provided a behind-the-scenes look at Octoblu’s platform, business, and pivots along the way (including the Citrix acquisition of Octoblu).
In his General Session at 17th Cloud Expo, Bruce Swann, Senior Product Marketing Manager for Adobe Campaign, explored the key ingredients of cross-channel marketing in a digital world. Learn how the Adobe Marketing Cloud can help marketers embrace opportunities for personalized, relevant and real-time customer engagement across offline (direct mail, point of sale, call center) and digital (email, website, SMS, mobile apps, social networks, connected objects).
The Internet of Everything is re-shaping technology trends–moving away from “request/response” architecture to an “always-on” Streaming Web where data is in constant motion and secure, reliable communication is an absolute necessity. As more and more THINGS go online, the challenges that developers will need to address will only increase exponentially. In his session at @ThingsExpo, Todd Greene, Founder & CEO of PubNub, exploreed the current state of IoT connectivity and review key trends and technology requirements that will drive the Internet of Things from hype to reality.
Two weeks ago (November 3-5), I attended the Cloud Expo Silicon Valley as a speaker, where I presented on the security and privacy due diligence requirements for cloud solutions. Cloud security is a topical issue for every CIO, CISO, and technology buyer. Decision-makers are always looking for insights on how to mitigate the security risks of implementing and using cloud solutions. Based on the presentation topics covered at the conference, as well as the general discussions heard between sessions, I wanted to share some of my observations on emerging trends. As cyber security serves as a fou...
Continuous processes around the development and deployment of applications are both impacted by -- and a benefit to -- the Internet of Things trend. To help better understand the relationship between DevOps and a plethora of new end-devices and data please welcome Gary Gruver, consultant, author and a former IT executive who has led many large-scale IT transformation projects, and John Jeremiah, Technology Evangelist at Hewlett Packard Enterprise (HPE), on Twitter at @j_jeremiah. The discussion is moderated by me, Dana Gardner, Principal Analyst at Interarbor Solutions.
Too often with compelling new technologies market participants become overly enamored with that attractiveness of the technology and neglect underlying business drivers. This tendency, what some call the “newest shiny object syndrome” is understandable given that virtually all of us are heavily engaged in technology. But it is also mistaken. Without concrete business cases driving its deployment, IoT, like many other technologies before it, will fade into obscurity.
With all the incredible momentum behind the Internet of Things (IoT) industry, it is easy to forget that not a single CEO wakes up and wonders if “my IoT is broken.” What they wonder is if they are making the right decisions to do all they can to increase revenue, decrease costs, and improve customer experience – effectively the same challenges they have always had in growing their business. The exciting thing about the IoT industry is now these decisions can be better, faster, and smarter. Now all corporate assets – people, objects, and spaces – can share information about themselves and thei...
The Internet of Things is clearly many things: data collection and analytics, wearables, Smart Grids and Smart Cities, the Industrial Internet, and more. Cool platforms like Arduino, Raspberry Pi, Intel's Galileo and Edison, and a diverse world of sensors are making the IoT a great toy box for developers in all these areas. In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists discussed what things are the most important, which will have the most profound effect on the world, and what should we expect to see over the next couple of years.
Discussions of cloud computing have evolved in recent years from a focus on specific types of cloud, to a world of hybrid cloud, and to a world dominated by the APIs that make today's multi-cloud environments and hybrid clouds possible. In this Power Panel at 17th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the importance of customers being able to use the specific technologies they need, through environments and ecosystems that expose their APIs to make true change and transformation possible.
Microservices are a very exciting architectural approach that many organizations are looking to as a way to accelerate innovation. Microservices promise to allow teams to move away from monolithic "ball of mud" systems, but the reality is that, in the vast majority of organizations, different projects and technologies will continue to be developed at different speeds. How to handle the dependencies between these disparate systems with different iteration cycles? Consider the "canoncial problem" in this scenario: microservice A (releases daily) depends on a couple of additions to backend B (re...
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Day 2 Keynote at 17th Cloud Expo, Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, wil...
PubNub has announced the release of BLOCKS, a set of customizable microservices that give developers a simple way to add code and deploy features for realtime apps.PubNub BLOCKS executes business logic directly on the data streaming through PubNub’s network without splitting it off to an intermediary server controlled by the customer. This revolutionary approach streamlines app development, reduces endpoint-to-endpoint latency, and allows apps to better leverage the enormous scalability of PubNub’s Data Stream Network.
The cloud. Like a comic book superhero, there seems to be no problem it can’t fix or cost it can’t slash. Yet making the transition is not always easy and production environments are still largely on premise. Taking some practical and sensible steps to reduce risk can also help provide a basis for a successful cloud transition. A plethora of surveys from the likes of IDG and Gartner show that more than 70 percent of enterprises have deployed at least one or more cloud application or workload. Yet a closer inspection at the data reveals less than half of these cloud projects involve production...
Apps and devices shouldn't stop working when there's limited or no network connectivity. Learn how to bring data stored in a cloud database to the edge of the network (and back again) whenever an Internet connection is available. In his session at 17th Cloud Expo, Ben Perlmutter, a Sales Engineer with IBM Cloudant, demonstrated techniques for replicating cloud databases with devices in order to build offline-first mobile or Internet of Things (IoT) apps that can provide a better, faster user experience, both offline and online. The focus of this talk was on IBM Cloudant, Apache CouchDB, and ...