|By Joe Winchester||
|December 1, 2008 01:22 PM EST||
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done. At this year's JavaOne, one of the keynote JavaFX demos bombed because the network was slow, something that would be forgivable had the entire application's UI not frozen, which required it to be restarted, only to trip up again a few minutes later.
A colleague of mine who was watching the demo suggested that the Java language should assert that network I/O cannot occur on the user interface thread. At first I thought this kind of extreme, but the more I thought about it the more sensible it seems.
Doing network I/O off the UI thread comes at a price; this extra work probably means that developers often just slam their code together and hope it doesn't crash. The application has to spawn a background thread to do an I/O that can communicate with the display, via the user interface thread, to update the display, perhaps adding rows to a list or painting in a graphics context. If, while the background thread is doing I/O, the user indicates that they wish to run a different search or get, the program has to cancel the old request and start a new one. This is often the hardest thing to do well and the one most often overlooked; just ask anyone who has pressed the "Cancel" button on a dialog when a task has just begun, only to watch the progress bar happily clock its way to completion before the application realizes that the task has been cancelled, whereupon it dutifully ditches the whole operation that, ironically for the user, they may now want to see.
Because it's hard to do good network and UI programming, developers often skip doing it well. This kind of sloppy programming manifests itself in many ways, from e-mail clients opening large attachments on the user interface thread without allowing any kind of cancel of ability to carry on working, to lists and trees that go and fetch all of their content from a slow network on the UI thread, preventing any further interaction with the GUI till the request is complete. It's not quite the blue screen of death; rather it's the "white screen of unconsciousness" - when the UI won't paint as the helpless user drags around dialogs in front of the application, which after a while the OS may realize is errant and reports it as "not responding." The application isn't broken; it's just waiting for a network request.
Java is an incredibly versatile language, which is its biggest strength; however, to write a good client/server application is still "caveat programmer" where the developer has to write lots of boilerplate code and make judgements about which I/O will and won't be slow. What if my colleague's hypothesis is right and all I/O should assert that it can't be run on the user interface thread, forcing developers to write better client/server programs. Users would get better software, and the language specifiers would soon be putting frameworks in place that could replace and supersede all of the boilerplate grunge out there that deals with deferred table population or cancellable polling dialogs. This would remove concerns and issues from the programmer about long-running blocking UI tasks by enforcing that all potentially slow I/O has to be run on a separate thread. Hopefully as a result all the classes and frameworks for painting graphics, filling lists, and dispatching tasks are built into the language to work this assumption and don't require forcing or finagling to become good citizens.
|collin fagan 12/10/08 10:56:18 AM EST|
The real issue is that the synchronous programming model fails in this type of situation.
I can see two options:
1. A completely asynchronous system. There is an asynchronous I/O systems that is part of NIO.2 (http://java.dzone.com/articles/hold-until-dec-8-tricks-and-ti). Making I/O into events would allow you to register I/O callbacks that could deliver data to the UI thread.
2. Make sure Swing is re-entrant and allow systems like foxtrot (http://foxtrot.sourceforge.net) which promises a synchronous programming model by spawning new threads to process the event queue instead of the worker task.
Unfortunately no one has ever succeeded in creating a multithreaded UI toolkit.
|[email protected] 12/01/08 05:22:49 PM EST|
It is not hard to do good network and UI programming - it is just *harder* than doing mediocre to bad UI programming (depending on the framework).
I do not support the idea of asserting that network I/O not be run on a UI thread because it is possible that you might actually want to do that, and it should be up to the coder to know this.
I *do* however support an assert that non-Swing event threads should not access "realized" Swing components (although most Java UI is not Swing or SWT anymore).
I have manually placed asserts in both network comm code and UI code to prevent these common mistakes - but I want the flexibility to choose.
Companies can harness IoT and predictive analytics to sustain business continuity; predict and manage site performance during emergencies; minimize expensive reactive maintenance; and forecast equipment and maintenance budgets and expenditures. Providing cost-effective, uninterrupted service is challenging, particularly for organizations with geographically dispersed operations.
May. 27, 2016 02:00 PM EDT Reads: 1,973
SYS-CON Events announced today that BMC Software has been named "Siver Sponsor" of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2015 at the Javits Center in New York, New York. BMC is a global leader in innovative software solutions that help businesses transform into digital enterprises for the ultimate competitive advantage. BMC Digital Enterprise Management is a set of innovative IT solutions designed to make digital business fast, seamless, and optimized from mainframe to mo...
May. 27, 2016 01:45 PM EDT Reads: 2,140
SoftLayer operates a global cloud infrastructure platform built for Internet scale. With a global footprint of data centers and network points of presence, SoftLayer provides infrastructure as a service to leading-edge customers ranging from Web startups to global enterprises. SoftLayer's modular architecture, full-featured API, and sophisticated automation provide unparalleled performance and control. Its flexible unified platform seamlessly spans physical and virtual devices linked via a world...
May. 27, 2016 01:15 PM EDT Reads: 2,163
The IoT is changing the way enterprises conduct business. In his session at @ThingsExpo, Eric Hoffman, Vice President at EastBanc Technologies, discuss how businesses can gain an edge over competitors by empowering consumers to take control through IoT. We'll cite examples such as a Washington, D.C.-based sports club that leveraged IoT and the cloud to develop a comprehensive booking system. He'll also highlight how IoT can revitalize and restore outdated business models, making them profitable...
May. 27, 2016 12:30 PM EDT Reads: 2,812
IoT generates lots of temporal data. But how do you unlock its value? How do you coordinate the diverse moving parts that must come together when developing your IoT product? What are the key challenges addressed by Data as a Service? How does cloud computing underlie and connect the notions of Digital and DevOps What is the impact of the API economy? What is the business imperative for Cognitive Computing? Get all these questions and hundreds more like them answered at the 18th Cloud Expo...
May. 27, 2016 12:00 PM EDT Reads: 2,219
SYS-CON Events announced today that EastBanc Technologies will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. EastBanc Technologies has been working at the frontier of technology since 1999. Today, the firm provides full-lifecycle software development delivering flexible technology solutions that seamlessly integrate with existing systems – whether on premise or cloud. EastBanc Technologies partners with p...
May. 27, 2016 10:30 AM EDT Reads: 2,216
SYS-CON Events announced today that Commvault, a global leader in enterprise data protection and information management, has been named “Bronze Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Commvault is a leading provider of data protection and information management...
May. 27, 2016 10:00 AM EDT Reads: 3,102
In his session at 18th Cloud Expo, Bruce Swann, Senior Product Marketing Manager at Adobe, will discuss 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). Bruce Swann has more than 15 years of experience working with digital marketing disciplines like web analytics, social med...
May. 27, 2016 10:00 AM EDT Reads: 1,297
SYS-CON Events announced today that Tintri Inc., a leading producer of VM-aware storage (VAS) for virtualization and cloud environments, will exhibit at the 18th International CloudExpo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, New York, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
May. 27, 2016 10:00 AM EDT Reads: 2,330
SYS-CON Events announced today Object Management Group® has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
May. 27, 2016 10:00 AM EDT Reads: 2,391
SYS-CON Events announced today that ContentMX, the marketing technology and services company with a singular mission to increase engagement and drive more conversations for enterprise, channel and SMB technology marketers, has been named “Sponsor & Exhibitor Lounge Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York City, New York. “CloudExpo is a great opportunity to start a conversation with new prospects, but what happens after the...
May. 27, 2016 09:45 AM EDT Reads: 1,077
The IoTs will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, will demonstrate how to move beyond today's coding paradigm and share the must-have mindsets for removing complexity from the development proc...
May. 27, 2016 09:00 AM EDT Reads: 1,888
What a difference a year makes. Organizations aren’t just talking about IoT possibilities, it is now baked into their core business strategy. With IoT, billions of devices generating data from different companies on different networks around the globe need to interact. From efficiency to better customer insights to completely new business models, IoT will turn traditional business models upside down. In the new customer-centric age, the key to success is delivering critical services and apps wit...
May. 27, 2016 08:45 AM EDT Reads: 1,126
Join us at Cloud Expo | @ThingsExpo 2016 – June 7-9 at the Javits Center in New York City and November 1-3 at the Santa Clara Convention Center in Santa Clara, CA – and deliver your unique message in a way that is striking and unforgettable by taking advantage of SYS-CON's unmatched high-impact, result-driven event / media packages.
May. 27, 2016 08:00 AM EDT Reads: 2,370
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, will provide an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life ...
May. 27, 2016 07:45 AM EDT Reads: 1,929
As cloud and storage projections continue to rise, the number of organizations moving to the cloud is escalating and it is clear cloud storage is here to stay. However, is it secure? Data is the lifeblood for government entities, countries, cloud service providers and enterprises alike and losing or exposing that data can have disastrous results. There are new concepts for data storage on the horizon that will deliver secure solutions for storing and moving sensitive data around the world. ...
May. 27, 2016 07:00 AM EDT Reads: 1,280
SYS-CON Events announced today that MobiDev will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business managers to a full-scale mobile software company with over 200 develope...
May. 27, 2016 06:15 AM EDT Reads: 2,548
WebRTC is bringing significant change to the communications landscape that will bridge the worlds of web and telephony, making the Internet the new standard for communications. Cloud9 took the road less traveled and used WebRTC to create a downloadable enterprise-grade communications platform that is changing the communication dynamic in the financial sector. In his session at @ThingsExpo, Leo Papadopoulos, CTO of Cloud9, will discuss the importance of WebRTC and how it enables companies to fo...
May. 27, 2016 05:15 AM EDT Reads: 2,496
SYS-CON Events announced today that MangoApps will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. MangoApps provides modern company intranets and team collaboration software, allowing workers to stay connected and productive from anywhere in the world and from any device. For more information, please visit https://www.mangoapps.com/.
May. 27, 2016 05:00 AM EDT Reads: 736
SYS-CON Events announced today TechTarget has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. TechTarget is the Web’s leading destination for serious technology buyers researching and making enterprise technology decisions. Its extensive global networ...
May. 27, 2016 04:45 AM EDT Reads: 3,143