• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multithreading

 
shankhas sanyal
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I need to implement multithreading concept in a piece of code that has single thread concept.

I have a class A that has a function called get makeReport that takes several inputs to fetch data from a DB and create a report.


In the current scenario everytime make report is called 1 thread is created.
How do I change the code so that everytime makeReport is called a new Thread is created ?

Many thanks for your help!

Shankha
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with Oracle's concurrency tutorial: http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html, particularly the "Thread Objects" chapter.
 
Luan Cestari
Ranch Hand
Posts: 163
C++ Redhat Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't recommend to create a new Thread everytime. Instead, use Thread pool, like http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic