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 8398639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:06:05+00:00 2026-06-09T21:06:05+00:00

I’m learning about concurrency in Clojure. I ran into a claim (by Stuart Serra?)

  • 0

I’m learning about concurrency in Clojure.

I ran into a claim (by Stuart Serra?) at http://dev.clojure.org/display/design/Scheduled+Events, stating:

  • Clojure functions cannot use time for control flow without blocking or Java interop
  • Java interop (ScheduledThreadPoolExecutor) is not aware of thread-local bindings

I don’t understand these claims and kindly ask for clarification, perhaps an example. Specifically:

  • What’s wrong with ScheduledThreadPoolExecutor as is? Since I’m starting a new (green) thread, I don’t expect per-thread bindings to carry over anyway.
  • I can schedule a normal Clojure function, so what’s stopping me to send desired bindings as lexically closed context?

Many thanks!

  • 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-06-09T21:06:06+00:00Added an answer on June 9, 2026 at 9:06 pm

    Ok, I think I got it.

    Suppose you try this:

    (def pool (atom nil))
    
    (defn- thread-pool []
        (or @pool
            (reset! pool (ScheduledThreadPoolExecutor. 1))))
    
    (def ^:dynamic *t* 0)
    
    (binding [*t* 1]
        (future (println "first example:" *t*)))
    
    (binding [*t* 1]
        (.schedule (thread-pool) (fn [] (println "second example:" *t*)) 0 
                   TimeUnit/SECONDS))
    
    (binding [*t* 1]
        (.schedule (thread-pool) (bound-fn [] (println "third example:" *t*)) 0
                   TimeUnit/SECONDS))
    

    The output will be:

    first example: 1
    second example: 0
    third example: 1
    

    In the first case, the future macro wraps the body with the private function binding-conveyor-fn, which preserves the calling thread’s bindings frame in the lexical scope, and restores it before calling the wrapped function.

    In the third case, bound-fn pushes the calling thread’s bindings onto the frame, executes the function body, and pops the bindings.

    In the second case, no one saves per-thread bindings – a Java class certainly doesn’t know about them, and so we drop to the root value of the t Var.

    I hope someone out there finds this interesting.

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

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

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.