Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do threads work in a regular program ?

 
Lee Sigauke
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have just started working with threads and I have a question: here's a scenario

If I have a program with Class A which has a main method, in this main method an instance of Class B is created and class B does "something". My question is if I run class A and and an instance of class B is made, would they be running on the same thread or on different threads ?
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java, if one method calls another method, the callee and caller execute on the same thread. To run code in a differrent thread, you will have to use the Java threading APi.
 
Lee Sigauke
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayesh A Lalwani wrote:In Java, if one method calls another method, the callee and caller execute on the same thread. To run code in a differrent thread, you will have to use the Java threading APi.


Thanks


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic