dcsimg
Problems starting Java threads on Linux
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pradeep_C
Posted On:   Sunday, October 6, 2002 01:37 AM

Hi, I am trying to run a thread based Java application on Linux. The problem i am facing here is that whenever i call the thread's start() function, the thread does not start running. However sometimes calling the thread's start() functions makes the thread run automatically. Something very strange. Any ideas why this is happening and how to overcome this problem. The same program works fine on Solaris. Linux Details> Kernel version 2.4.xx Java IBM's jre 1.3.0 Solaris Details> Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0) Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)    More>>

Hi,


I am trying to run a thread based Java application on Linux. The problem i am facing here is that whenever i call the thread's start() function, the thread does not start running.




However sometimes calling the thread's start() functions makes the thread run automatically. Something very strange. Any ideas why this is happening and how to overcome this problem.




The same program works fine on Solaris.




Linux Details>
Kernel version 2.4.xx
Java IBM's jre 1.3.0




Solaris Details>
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)



Thanks,
pradeep    <<Less

Re: Problems starting Java threads on Linux

Posted By:   Simon_Ablett  
Posted On:   Monday, October 7, 2002 08:22 AM

Could be a starvation issue i.e. your main thread is taking up all of the CPU cycles and not allowing your secondary threads to get any of the cycles. Try adding a 'sleep' in your main thread. Doing this will at least let you know if it is being starved. Are you using native rather than green threads? I am not sure what threading model Linux uses by default (i.e. pre-emptive or time-sliced).

A point to note is that your thread does not necessarily run when you call the start method. all that happens at that point is that the thread is flagged as being active (i.e. available to run) so that the scheduler can run it whenever the necessary resources (i.e. CPU cycles) become available.

Regards.
About | Sitemap | Contact