Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7627655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:29:18+00:00 2026-05-31T05:29:18+00:00

I have a link that will allow users to click it and it fetches

  • 0

I have a link that will allow users to click it and it fetches a zip file of photos. If the zip file doesn’t exist, it then starts a thread to create the zip and displays a message back to the user that the photos are currently being processed.

What I’m trying to avoid is a user clicking the link repeatedly and setting off a whole mass of threads that will try create/update the zip file. The zip file processing is quite system resource intensive so I only want to allow the application to generate one zip at a time. If one is busy being compiled, it should just do nothing and queue the requests.

Currently how I am handling it is with a cflock around the thread:

<cflock name="createAlbumZip" type="exclusive" timeout="30" throwontimeout="no">
  <cfthread action="run" albumId="#arguments.albumId#" name="#CreateUUID()#">
    ....

What I am hoping occurs here (it seems to be working if I test it) is that it will check if there is currently a thread running using a lock called ‘createAlbumZip’. If there is, it will queue the request for 30 seconds after which it should timeout without any error. If it wasn’t able to create it within the 30 seconds that is fine.

So – this seems to be working, but my question is: Is this the best way to handle a scenario like this? Is locking the right approach? Are there any shortcomings that could arise from this approach that I don’t see?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:29:19+00:00Added an answer on May 31, 2026 at 5:29 am

    There are a million ways to skin this cat. Locking is a good start, and as per your comment on @Pat Branley’s answer, I think your locking outside the thread creation might be a little more efficient for just the reason you propose: the potential would exist to create dozens of threads whose whole lifespan will consist of waiting for a lock to open or timeout.

    The other thing you need to do is double up on the IF statement:

    <cfif not (zip file exists)>
      <cflock ...>
        <cfif not (zip file exists)>
          <cfthread>
            ...create zip...
          </cfthread>
        </cfif>
      </cflock>
    </cfif>
    

    This will prevent the case where thread B is waiting while thread A creates the zip, and then thread A finishes, and thread B proceeds to recreate/overwrite it.

    In addition, you could consider something like using JavaScript to prevent extra clicks by disabling the button/link after it’s been clicked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to code a page that will only allow users that click on
Does anyone have an example (code or a link) that will allow me to
I have made an about box that is meant to allow users to click
Built a custom app that will allow users to add jobs to a system.
We have a custom web app in our intranet that allow users to browse
I'm trying to build a form that will list all users and allow you
I have a servlet that allows users to download (potentially large) zip files from
Alright so I want my users to be able to click a link that
I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have a link that I dynamically create which looks something like the following:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.