Code Monkey home page Code Monkey logo

Comments (4)

jneira avatar jneira commented on June 11, 2024

Hi! I think you have made a typo in your example, i suppose it is:

foreign export java "@static eta.example.MyClass.sayAnything" sayAnythingEta :: String -> IO ()
sayAnythingEta text = do
  putStrLn text
  return ()

I've just test something similar with lastest etlas and eta and it worked for me.
What do you mean with "java multi-thread environment"?

from eta.

Boreaso avatar Boreaso commented on June 11, 2024

@jneira Hello, jneira, thank you for your answer. Actually, my program is multi-threaded, I want to call this function in multi-threaded state. Just like this:

public static void main(String[] args) {
        ThreadPoolExecutor threadPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(100);

        long t0 = System.currentTimeMillis();

        for (int i = 0; i < 10; i++) {
            threadPool.execute(new Thread() {
                @Override
                public void run() {
                     eta.example.MyClass.sayAnything("Hello eta.");
                }
            });
        }

        threadPool.shutdown();
        try {
            threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        long t1 = System.currentTimeMillis();

        System.out.println("Time: " + (t1 - t0));
}

How can I achieve this?

from eta.

jneira avatar jneira commented on June 11, 2024

I've reproduced the error in a test project: https://github.com/jneira/eta-test/blob/print-ffi/java/Utils.java#L47-L71
It may be a bug in the runtime (maybe @rahulmutt could confirm it)

from eta.

Boreaso avatar Boreaso commented on June 11, 2024

@rahulmutt Is there any solution to this problem?

from eta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.