Create templateWithLimit

same as template but with a synchronization variable