Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can multiple threads be in Running state

 
ravindra patil
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am bit confused , can i have more than 1 thread which are in running state simultaneously ,if yes then why jvm pickups high priority thread to run


 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sure. If the machine has more than one core (processor), then it's possible for more than one thread to be running at the same time.

Henry
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you referring to runnable thread state ?

If yes, then this does not mean that the thread is currently executing. It may be swapped out by the OS scheduler. Java thread states does not reflect whether the thread is actually processing an instruction at that particular moment. However, in most of the cases, you would not be bothered about that.

Irrespective of whether there are multiple cores or a hyper-threaded processor, any number of threads can be in a runnable state but based on the number of processors, that many number of threads can execute an instruction concurrently.
 
vendikonda sravan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it is true that two therads can be in running State what about synchronized methods(i.e if we make run it self as synchronized) will the threads run parallel ?

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vendikonda sravan wrote: if it is true that two therads can be in running State what about synchronized methods(i.e if we make run it self as synchronized) will the threads run parallel ?



This is totally different story, it's depends on the methods, in which object they have been synchronized. A synchronized method of a object can't be run by two different Thread at the same time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!