Simple explanation of how a hash timelock function works with an atomic trade of bitcoin / litecoin trade without a 3rd party?
I am leaving out a few details here, but this will get you thinking on the right path...

Alice and Bob have accounts on both the Bitcoin and Litecoin networks. Bob has Bitcoin, but wants Litecoin. Alice has Litecoin and wants Bitcoin. They do not trust each other.

Both agree to trade Bob's 1 Bitcoin for 2.5 of Alice's Litecoin. 

Alice starts the transaction with a contract on the Litecoin network. The contract states that she will deposit 2.5 Litecoin into Bob's Litecoin account, if Bob can provide a password (called a "Preimage") that produces a certain hash. If Bob does not provide the preimage within 21 hours, the Litecoin goes back into Alice's account.

So, the contract has Alice's account, Bob's account, 2.5 Litecoin, the hash of the preimage, and 21 hour expiry.

Bob can examine the contract by browsing the blockchain. He can see if he likes the terms. If he does, he can build a contract on the Bitcoin blockchain. That contract is very similar. It has:

Bob's account, Alice's account, 1 Bitcoin, the same hash that appeared in the contract on the Litecoin network, and a 10 hour expiry.

Alice can examine the contract on the Bitcoin network. If she likes the terms, she can use her preimage to "unlock" the 1 bitcoin. When she does, that preimage is published on the Bitcoin blockchain, and Bob can see it. He uses that preimage to "unlock" his 2.5 Litecoin on the Litecoin network.