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.