Java IoT Authors: Liz McMillan, Elizabeth White, Yeshim Deniz, Ruxit Blog, TJ Randall

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$Thread2.run(SimpleDeadLock.java:37)
- 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$Thread1.run(SimpleDeadLock.java:24)
- 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
    . ./setWLSEnv.sh
    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
    . ./setWLSEnv.sh

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
. ./setWLSEnv.sh

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
SYS-CON Events announced today that Streamlyzer will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Streamlyzer is a powerful analytics for video streaming service that enables video streaming providers to monitor and analyze QoE (Quality-of-Experience) from end-user devices in real time.
You have great SaaS business app ideas. You want to turn your idea quickly into a functional and engaging proof of concept. You need to be able to modify it to meet customers' needs, and you need to deliver a complete and secure SaaS application. How could you achieve all the above and yet avoid unforeseen IT requirements that add unnecessary cost and complexity? You also want your app to be responsive in any device at any time. In his session at 19th Cloud Expo, Mark Allen, General Manager of...
Established in 1998, Calsoft is a leading software product engineering Services Company specializing in Storage, Networking, Virtualization and Cloud business verticals. Calsoft provides End-to-End Product Development, Quality Assurance Sustenance, Solution Engineering and Professional Services expertise to assist customers in achieving their product development and business goals. The company's deep domain knowledge of Storage, Virtualization, Networking and Cloud verticals helps in delivering ...
Intelligent machines are here. Robots, self-driving cars, drones, bots and many IoT devices are becoming smarter with Machine Learning. In her session at @ThingsExpo, Sudha Jamthe, CEO of IoTDisruptions.com, will discuss the next wave of business disruption at the junction of IoT and AI, impacting many industries and set to change our lives, work and world as we know it.
SYS-CON Events announced today that 910Telecom will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Housed in the classic Denver Gas & Electric Building, 910 15th St., 910Telecom is a carrier-neutral telecom hotel located in the heart of Denver. Adjacent to CenturyLink, AT&T, and Denver Main, 910Telecom offers connectivity to all major carriers, Internet service providers, Internet backbones and ...
The IoT industry is now at a crossroads, between the fast-paced innovation of technologies and the pending mass adoption by global enterprises. The complexity of combining rapidly evolving technologies and the need to establish practices for market acceleration pose a strong challenge to global enterprises as well as IoT vendors. In his session at @ThingsExpo, Clark Smith, senior product manager for Numerex, will discuss how Numerex, as an experienced, established IoT provider, has embraced a ...
Cloud based infrastructure deployment is becoming more and more appealing to customers, from Fortune 500 companies to SMEs due to its pay-as-you-go model. Enterprise storage vendors are able to reach out to these customers by integrating in cloud based deployments; this needs adaptability and interoperability of the products confirming to cloud standards such as OpenStack, CloudStack, or Azure. As compared to off the shelf commodity storage, enterprise storages by its reliability, high-availabil...
DevOps is being widely accepted (if not fully adopted) as essential in enterprise IT. But as Enterprise DevOps gains maturity, expands scope, and increases velocity, the need for data-driven decisions across teams becomes more acute. DevOps teams in any modern business must wrangle the ‘digital exhaust’ from the delivery toolchain, "pervasive" and "cognitive" computing, APIs and services, mobile devices and applications, the Internet of Things, and now even blockchain. In this power panel at @...
The Quantified Economy represents the total global addressable market (TAM) for IoT that, according to a recent IDC report, will grow to an unprecedented $1.3 trillion by 2019. With this the third wave of the Internet-global proliferation of connected devices, appliances and sensors is poised to take off in 2016. In his session at @ThingsExpo, David McLauchlan, CEO and co-founder of Buddy Platform, discussed how the ability to access and analyze the massive volume of streaming data from millio...
In the next forty months – just over three years – businesses will undergo extraordinary changes. The exponential growth of digitization and machine learning will see a step function change in how businesses create value, satisfy customers, and outperform their competition. In the next forty months companies will take the actions that will see them get to the next level of the game called Capitalism. Or they won’t – game over. The winners of today and tomorrow think differently, follow different...
“Media Sponsor” of SYS-CON's 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. CloudBerry Backup is a leading cross-platform cloud backup and disaster recovery solution integrated with major public cloud services, such as Amazon Web Services, Microsoft Azure and Google Cloud Platform.
According to Forrester Research, every business will become either a digital predator or digital prey by 2020. To avoid demise, organizations must rapidly create new sources of value in their end-to-end customer experiences. True digital predators also must break down information and process silos and extend digital transformation initiatives to empower employees with the digital resources needed to win, serve, and retain customers.
SYS-CON Events announced today that SoftNet Solutions will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. SoftNet Solutions specializes in Enterprise Solutions for Hadoop and Big Data. It offers customers the most open, robust, and value-conscious portfolio of solutions, services, and tools for the shortest route to success with Big Data. The unique differentiator is the ability to architect and ...
You think you know what’s in your data. But do you? Most organizations are now aware of the business intelligence represented by their data. Data science stands to take this to a level you never thought of – literally. The techniques of data science, when used with the capabilities of Big Data technologies, can make connections you had not yet imagined, helping you discover new insights and ask new questions of your data. In his session at @ThingsExpo, Sarbjit Sarkaria, data science team lead ...
A completely new computing platform is on the horizon. They’re called Microservers by some, ARM Servers by others, and sometimes even ARM-based Servers. No matter what you call them, Microservers will have a huge impact on the data center and on server computing in general. Although few people are familiar with Microservers today, their impact will be felt very soon. This is a new category of computing platform that is available today and is predicted to have triple-digit growth rates for some ...
In past @ThingsExpo presentations, Joseph di Paolantonio has explored how various Internet of Things (IoT) and data management and analytics (DMA) solution spaces will come together as sensor analytics ecosystems. This year, in his session at @ThingsExpo, Joseph di Paolantonio from DataArchon, will be adding the numerous Transportation areas, from autonomous vehicles to “Uber for containers.” While IoT data in any one area of Transportation will have a huge impact in that area, combining sensor...
SYS-CON Events announced today that Transparent Cloud Computing (T-Cloud) Consortium will exhibit at the 19th International Cloud Expo®, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. The Transparent Cloud Computing Consortium (T-Cloud Consortium) will conduct research activities into changes in the computing model as a result of collaboration between "device" and "cloud" and the creation of new value and markets through organic data proces...
SYS-CON Events announced today that Niagara Networks will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Niagara Networks offers the highest port-density systems, and the most complete Next-Generation Network Visibility systems including Network Packet Brokers, Bypass Switches, and Network TAPs.
SYS-CON Media announced today that @WebRTCSummit Blog, the largest WebRTC resource in the world, has been launched. @WebRTCSummit Blog offers top articles, news stories, and blog posts from the world's well-known experts and guarantees better exposure for its authors than any other publication. @WebRTCSummit Blog can be bookmarked ▸ Here @WebRTCSummit conference site can be bookmarked ▸ Here
In today's uber-connected, consumer-centric, cloud-enabled, insights-driven, multi-device, global world, the focus of solutions has shifted from the product that is sold to the person who is buying the product or service. Enterprises have rebranded their business around the consumers of their products. The buyer is the person and the focus is not on the offering. The person is connected through multiple devices, wearables, at home, on the road, and in multiple locations, sometimes simultaneously...