• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multithreading

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
reply
    Bookmark Topic Watch Topic
  • New Topic