Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is meant by single threaded

 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i read session is single threade what is meant by single threaded.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means a program runs in one thread.
 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so a partcular session cant be spawned to another thread.
a session object created in a thread will end in the same thread.
is that correct.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so a partcular session cant be spawned to another thread.

I'm not sure what you been by "spawned" in this context. Any object can be passed to any thread. Whether the object still works correctly if it is used in another thread is a different question, though. The javadocs should cover that. A still different question is whether an object can be used in several threads simultaneously; this, too, should be covered in the javadocs.

a session object created in a thread will end in the same thread. is that correct.

No; see above. It's trivial to pass an object from one thread into another thread.
 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please explain me in case of org.hibernate.Session
they say Session is single threaded.
and single threaded " it means a program runs in one thread."
i am not able to understand why session is single threaded.
is session exists in the present thread only?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An object is not single-threaded; an application is (or is not).

So you're talking about org.hibernate.Session. What those javadocs actually say is that it is not safe to use a Session object in more than one thread. If your code has multiple threads, then each thread needs to obtain its own Session object.

Objects are often not made thread-safe because of performance reasons, or because through the way they're used non-thread-safety is not perceived as a problem.
 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm i got it
very thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic