1

In my simulation project i am simulating web requests through Runnable objects that either sleep for specified milliseconds or keep processor busy through spin. But the response times of simulated http requests are little more than expected due to impreciseness of Thread.sleep() and i want to replace this pause with some other technique. I cant use spin as it will eat cpu-cycles also i need to simulate an I/O boundness by taking a pause. I have searched alternatives of sleep and could not find to take a pause in java other than Thread.sleep,spin or wait. I cant use wait as it is also imprecise. No guarantee of precise times in wait too. In answer#2 of this question Peter Lawrey talked about data driven simulated clock, but i have also search about it but did not find any tutorials or its implementation in java. Is there any one who can just give a simple example in java how i can implement my own dta driven simulated clock so that i can take myself out of Thread.sleep() trouble.

Community
  • 1
  • 1
Faisal Bahadur
  • 498
  • 3
  • 19
  • You should start by telling us what your simulation task is. It was vague in the original question and it is vaguer now. It's hard to tell whether Peter's answer is applicable to your task and how if we don't know what your task is. – RealSkeptic Nov 15 '15 at 10:58
  • so how should i change this question now i am new to stackoverflow – Faisal Bahadur Nov 15 '15 at 11:14
  • You should explain your simulation task, or the part of it that is relevant at the moment. You should also show what your original approach was - this is very important because without it, people here on SO will tend to think you are just asking us to do your work for you. So - task description, original approach, link to question and answer. And since you are new, I recommend reading the [help]. – RealSkeptic Nov 15 '15 at 11:23
  • plz read my edited question and help me if u can! – Faisal Bahadur Nov 15 '15 at 11:29
  • First you deleted my edit where I sorted out your linking issues. Second, no one is going to read that wall of text. Much like code, text should follow the SRP - you need to split first into paragraphs then into short and cogent sentences. If you need to, use headed sections too. – Boris the Spider Nov 16 '15 at 08:04

0 Answers0