This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Multithreading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Multithreading" Watch "Multithreading" New topic
Author

Multithreading

shankhas sanyal
Ranch Hand

Joined: Jun 15, 2008
Posts: 45
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


I love this place!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41035
    
  43
Start with Oracle's concurrency tutorial: http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html, particularly the "Thread Objects" chapter.


Ping & DNS - my free Android networking tools app
Luan Cestari
Ranch Hand

Joined: Feb 07, 2010
Posts: 162

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 .


Please, visit me for some cool tech post at www.ourdailycodes.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multithreading
 
Similar Threads
Best approach to Thread
threads
Locking and remoteException
Threads - enough is enough
Question on singletons