Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating threads scheduling in java (stackless java?)

For some academic research I need to simulate several threads running on a single processor.

I want to be able to insert *call_scheduler()* calls inside my code, in which the current "thread" will pause (remembering in which code line it is) and some scheduling function will decide which thread to let go.

In python, this could be implemented neatly using stackless python. Is there a java alternative?

I could implement it using real threads and some messaging queues (or pipes) that will force only one thread to run at a time - but this is an ugly and problematic solution.

like image 456
Oren Avatar asked Dec 11 '25 20:12

Oren


1 Answers

For cooperative user threads you could use Apache javaflow continuations: http://commons.apache.org/sandbox/javaflow/

I'd be interested in knowing how to implement a preemptive scheduler with this continuations package

like image 126
francesc Avatar answered Dec 14 '25 08:12

francesc