Home > Articles > Programming > User Interface (UI)

  • Print
  • + Share This
Like this article? We recommend

Conclusion

Implementing multithreaded Java code is reasonably straightforward. Even converting existing single-threaded Java GUI code to a multithreaded format is not difficult. The results are actually quite impressive: Your GUI is freed up from long waits and ready to process other user actions. However, your application might or might not permit the interleaving of operations; imagine an application that fetches customer names from a database before printing out invoices. It wouldn't make much sense to put the printing code in a separate thread and then try to print invoices before customer names had been read from the database!

For application operations where it's okay to interleave user actions, making a GUI multithreaded can be very useful. It can even help to improve end user productivity by allowing a number of application operations to proceed in parallel.

However, the power that multithreaded programming provides should be used with care. If you use shared data across threads, then it's quite easy to get into some very difficult debugging scenarios. The same is true of locking shared resources between threads. The rule of thumb is to follow the guidelines and start out being conservative in your multithreaded designs. As you get more experienced with the use of multithreaded programming, you can then start to use the more powerful features.

  • + Share This
  • 🔖 Save To Your Account