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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:03:29+00:00 2026-06-07T23:03:29+00:00

I have many examples of Java bytecode, all of which I’d like to execute

  • 0

I have many examples of Java bytecode, all of which I’d like to execute from Clojure. Each sequence of bytecode may contain an infinite loop, in which case I’d like to stop running it after a couple of seconds. I’ve been looking at futures as a means of doing this. Having hunted around for a couple of implementations I’ve tried both this code:

(deref (future (loop[a 1] (recur a)) :done!) 1000 :impatient!)

…and also the code at https://gist.github.com/3124000

In both cases, the loop appears to be timed out appropriately (and in the latter case the future is reported to have been both done and cancelled), but I see my CPU usage rise to 99% or thereabouts and stay there. I also see that each time I run this code, my Java process gains an extra thread.

It looks to me like the future is being cancelled, but the code is still running. In my program I will need to run, and time out, some very tight infinite loops (e.g. the Java bytecode equivalent of “20 PRINT GOTO 10”) and I don’t have the option of modifying the code that I’m running.

Any ideas why I’m seeing this behaviour; what I could do to prevent it; or alternative methods for me to realise my aim of running and timing out such code?

  • 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-07T23:03:31+00:00Added an answer on June 7, 2026 at 11:03 pm

    The only way I’ve found to actual kill a the code executing inside a thread is to use the deprecated .stop method. In a lot of cases, the reason that it is deprecated isn’t really important.

    I had a function in clojail for doing just that. Feel free to snatch the function out or just pull in the library.

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

Sidebar

Related Questions

Am tearing my hair out here. Have read many examples which describe how to
I'm trying to add values from array to DB, have tried many variuos examples
I have a question about wiring web server controls. From many of the examples
In many examples I have seen online, AsyncTask is extended, the constructor is overriden,
i have a general question about properties and ivars. ive seen many different examples
Greetings everybody. I have seen examples of such operations for so many times that
I would like to embed Clojure code into Java. This site was helpful in
I have found many references explaining how to programmatically compile a Java class using
I have Java application which adds JTextFields @ runtime to JPanel. Basically user clicks
I have a good understanding of OO from java and C# and I'm lucky

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.