java - Manipulate Thread Implementation in JVM -


recently, i've been working on deployment of concurrent objects onto multicore. in sample, use blockingqueue.take() method specification mentions blocking. means method not release enclosing thread's resources such can re-used other concurrent tasks. useful since total number of live threads in jvm instance limited , if application need thousands of live threads, vital able re-use suspended threads. on other hand, jvm uses 1:1 mapping application-level threads os-level threads in java; i.e. each java thread instance becomes underlying os-level thread.

the current solution based on java.util.concurrency in java 1.5+. still, need worker threads such scalable large number. now, interested find following answers:

  • is there way replace implementation of java.lang.thread in jvm such can plug own thread implementation?
  • is possible through tweaking c++ sections of thread implementation in jvm , recompiling it?
  • is there library provide way replace classical thread in java?
  • again, in same line, there library or way guide how some threads in java can mapped only one thread in os-level?

i found this discussing different implementations of jvm , not sure if help.

thanks comments , ideas in advance.

if creating thousands of threads, you're doing wrong.

instead, consider using executor framework. (start executors , threadpoolexecutor classes.) allow queue thousands of tasks while having sane number of threads handling them.

i guess approach meant "library replace classical threads". highly recommend executors.

one caveat: executors, default, use non-daemon threads. therefore, must shut down executor when you're done it. can @ program exit, if there normal way exit program doesn't involve waiting threads finish. :-)


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -