Concurrency is hard: Java vs Python pitfalls you can't ignore

  • Authors

    • Madhurima Kommuru Sr. Java Developer at Claritev, USA. Author

    DOI:

    https://doi.org/10.67228/30716357/IJMRSE-2022PII8E1Y

    Published 12-05-2022

  • Concurrency, Multithreading, Java, Python, Gil, Race Conditions, Deadlocks, Parallelism, Synchronization, Performance

    Issue

    Section

    Articles

    How to Cite

    Concurrency is hard: Java vs Python pitfalls you can’t ignore. (2022). International Journal of Modern Research in Science & Engineering, 5(2), 01-18. https://doi.org/10.67228/30716357/IJMRSE-2022PII8E1Y
  • Abstract

    Concurrency is touted as the route to faster, more responsive software, yet it continues to be one of the hardest things to master in programming today. As software gets distributed over multiple CPU cores, machines, and interacts with users in real-time, it is the developer who has to orchestrate the simultaneous execution of multiple tasks very skillfully to avoid tricky and unusual bugs. This paper examines the practical challenges developers face when implementing concurrency in Java and Python by first presenting a comparative analysis of two very popular programming languages, namely Java and Python. Both languages support concurrent programming, but they differ significantly in their models, tools, and limitations. Java through its comprehensive multithreading and concurrency API, and Python through its simpler syntax which however comes with a very serious limitation in the form of the GIL (Global Interpreter Lock). This comparison highlights how these architectural decisions profoundly affect the ways in which programmers interact with the language, how efficient the programs are, and how dependable they turn out. Our narrative revolves around concurrency-related mishaps such as race conditions, deadlocks, thread starvation, and inconsistent state management, which arise in distinctive ways in the two considered languages. Java programmers are confronted with the need to synchronize threads correctly and prevent over-engineering while Python developers have to find ways of circumventing constraints that hinder parallelism. By looking at examples of real-life concurrency dilemmas and the respective solutions that have emerged over time, the paper explains how minor oversights can result in massive outages.

  • References

    [1] Hollings, Tracey, et al. "How do you find the green sheep? A critical review of the use of remotely sensed imagery to detect and count animals." Methods in Ecology and Evolution 9.4 (2018): 881-892.

    [2] Wang, Chao, et al. "smartpip: A smart approach to resolving python dependency conflict issues." Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering. 2022.

    [3] Suryadevara, S. S. K. (2021). AI-Driven Multi-Cloud Orchestration System for Enterprise Digital Experience Delivery. American International Journal of Computer Science and Technology, 3(1), 21-34. https://doi.org/10.63282/3117-5481/AIJCST-V3I1P103

    [4] Muppaneni, K. (2021). HTTP/3 & REST Latency Improvement. International Journal of Emerging Research in Engineering and Technology, 2(1), 122-132. https://doi.org/10.63282/3050-922X.IJERET-V2I1P113

    [5] Van Rossum, Guido, and Jelke De Boer. "Interactively testing remote servers using the Python programming language." CWI quarterly 4.4 (1991): 283-303.

    [6] Kumar Doodala, A. N. (2021). Intelligent EOB/ERA Generation and Validation Framework on Legacy Systems like Mainframes. International Journal of Emerging Research in Engineering and Technology, 2(1), 111-121. https://doi.org/10.63282/3050-922X.IJERET-V2I1P112

    [7] Rodriguez, Michael, Joel Tonyan, and Robert T. Wilson. "Tools and techniques for troubleshooting remote access." Journal of Electronic Resources Librarianship 30.3 (2018): 171-178.

    [8] Muppaneni, R. K. (2021). Securing the Enterprise: How Dynamics 365 Meets Global Compliance Standards. International Journal of Emerging Research in Engineering and Technology, 2(1), 133-143. https://doi.org/10.63282/3050-922X.IJERET-V2I1P114

    [9] Zhao, Yutong, et al. "A large-scale empirical study of real-life performance issues in open source projects." IEEE Transactions on Software Engineering 49.2 (2022): 924-946.

    [10] Vppalapati, M. (2021). The Geometry of Redundancy: Why Physically Separate Storage Paths Behave as One System. International Journal of Emerging Research in Engineering and Technology, 2(2), 107-116. https://doi.org/10.63282/3050-922X.IJERET-V2I2P113

    [11] Langtangen, Hans Petter. Python scripting for computational science. Berlin, Heidelberg: Springer Berlin Heidelberg, 2006.

    [12] Gaddam, R. R. (2021). Vertex AI as a Unified Control Plane for MLOps. International Journal of Artificial Intelligence, Data Science, and Machine Learning, 2(2), 92-102. https://doi.org/10.63282/3050-9262.IJAIDSML-V2I2P110

    [13] Srigadde, B. R. (2020). When Force Is With You but Not Lightning Component. American International Journal of Computer Science and Technology, 2(1), 23-33. https://doi.org/10.63282/3117-5481/AIJCST-V2I1P103

    [14] Slatkin, Brett. Effective python: 90 specific ways to write better python. Addison-Wesley Professional, 2019.

    [15] Muppaneni, K. (2021). Cross-Browser Debugging Strategies. American International Journal of Computer Science and Technology, 3(5), 25-36. https://doi.org/10.63282/3117-5481/AIJCST-V3I5P103

    [16] BVF``Kong, Qingkai, Timmy Siauw, and Alexandre Bayen. Python programming and numerical methods: A guide for engineers and scientists. Academic Press, 2020.

    [17] Shiramalla, R., & Guntupalli, B. . (2021). Cost-Effective Softphone Integration in CRM Platforms Using RESTful APIs: A Salesforce Case Study for Voice-to-Text Sales Enablement. International Journal of Emerging Trends in Computer Science and Information Technology, 2(1), 101-114. https://doi.org/10.63282/3050-9246.IJETCSIT-V2I1P112

    [18] Bauer, Andrew C., et al. "In situ methods, infrastructures, and applications on high performance computing platforms." Computer Graphics Forum. Vol. 35. No. 3. 2016.

    [19] Vppalapati, M., & Talasila, P. K. (2021). Failure without Faults: How Enterprise Storage Systems Degrade Long Before They Break. International Journal of Emerging Trends in Computer Science and Information Technology, 2(1), 115-123. https://doi.org/10.63282/3050-9246.IJETCSIT-V2I1P113

    [20] Julian, Mike. Practical Monitoring: Effective Strategies for the Real World. " O'Reilly Media, Inc.", 2017.

    [21] Muppaneni, R. K. (2021). How Enterprises are Achieving 360° Customer Views with Dynamics 365. International Journal of AI, BigData, Computational and Management Studies, 2(2), 129-138. https://doi.org/10.63282/3050-9416.IJAIBDCMS-V2I2P114

    [22] Srigadde, B. R., & Talakola, S. (2020). How to Open a Modal Using Quick Action on the Record Detail Page. International Journal of Artificial Intelligence, Data Science, and Machine Learning, 1(2), 43-51. https://doi.org/10.63282/3050-9262.IJAIDSML-V1I2P105

    [23] Boccignone, Giuseppe, et al. "pyVHR: a Python framework for remote photoplethysmography." PeerJ Computer Science 8 (2022): e929.

    [24] Suryadevara, S. S. K. (2021). Generative AI–Powered Authoring Assistant for Enterprise Content Management. International Journal of Artificial Intelligence, Data Science, and Machine Learning, 2(2), 103-113. https://doi.org/10.63282/3050-9262.IJAIDSML-V2I2P111

    [25] Ravasi, Matteo, and Ivan Vasconcelos. "PyLops—A linear-operator Python library for scalable algebra and optimization." SoftwareX 11 (2020): 100361.

    [26] Allenki, S. S., & Korutla, R. (2021). Agile Development in Practice: From Intern to Contributor. International Journal of Artificial Intelligence, Data Science, and Machine Learning, 2(3), 91-103. https://doi.org/10.63282/3050-9262.IJAIDSML-V2I3P110

    [27] Parakala, A. (2021). Building Analytics-Driven Bots: RPA Meets Business Intelligence. International Journal of Emerging Research in Engineering and Technology, 2(1), 77-87. https://doi.org/10.63282/3050-922X.IJERET-V2I1P109

    [28] Zhou, Chengquan, et al. "An automated, high-performance approach for detecting and characterizing broccoli based on UAV remote-sensing and transformers: A case study from Haining, China." International Journal of Applied Earth Observation and Geoinformation 114 (2022): 103055.

    [29] Katangoori, S., & Katangoori, A. (2021). AI-Augmented Data Governance: Enabling Intelligent Access, Lineage, and Compliance across Hybrid Clouds. American International Journal of Computer Science and Technology, 3(6), 36-45. https://doi.org/10.63282/3117-5481/AIJCST-V3I6P104

    [30] Zakria, Zakria, et al. "Multiscale and direction target detecting in remote sensing images via modified YOLO-v4." IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing 15 (2022): 1039-1048.

    [31] Gaddam, R. R. (2021). Hermetic ML Environments using Conda-Lock and Docker. American International Journal of Computer Science and Technology, 3(4), 22-34. https://doi.org/10.63282/3117-5481/AIJCST-V3I4P103

    [32] Wang, Ying, et al. "Watchman: Monitoring dependency conflicts for python library ecosystem." Proceedings of the ACM/IEEE 42nd international conference on software engineering. 2020.

  • Downloads