# TIP: Use the Two Phase Commit Algorithm for Offline Support

DevFeed: [TIP: Use the Two Phase Commit Algorithm for Offline Support](<https://devfeed.tech/articles/tip-use-the-two-phase-commit-algorithm-for-offline-support-19609.md>)

Original publisher: [Read original article](<https://www.codenameone.com/blog/tip-use-two-phase-commit-for-offline/>)

Author: Shai Almog

Published: 2018-07-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [CodeName One](<https://devfeed.tech/sources/codename-one.md>)

Topics: [Mobile](<https://devfeed.tech/topics/mobile.md>), [Algorithms, Complexity](<https://devfeed.tech/topics/algorithms-complexity.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [algorithms](<https://devfeed.tech/tags/algorithms.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [offline](<https://devfeed.tech/tags/offline.md>)

## AI overview

This tutorial explains two-phase commit and how it can support offline and online operation in mobile apps. It introduces transactions, describes the two commit phases, and outlines risks such as conflicts, synchronization problems, and unreliable connections.

## Source excerpt

I used to do a lot of enterprise consulting in the day and used to lecture a lot on J2EE (as it was known back then). A lot of that knowledge isn't as applicable even in the server side today, but the algorithms are surprisingly even applicable in mobile. One of the algorithms I would explain a lot when teaching J2EE was the 2PC AKA Two Phase Commit.