File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Implications of a singleton Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Implications of a singleton Thread" Watch "Implications of a singleton Thread" New topic
Author

Implications of a singleton Thread

adithya narayan
Ranch Hand

Joined: Jan 05, 2009
Posts: 79

I was just thinking of making a single object of a thread i.e. a singleton so that i have made just a single Thread object in my entire application.
Its job will be same whenever i call. The purpose of doing it is simple. I don't want to make the process run in the main application thread.

I also would like to synchronize the job (work done by runnable) if the job is called from multiple locations.

I wanted to know how good this design will be and what can be the pros and cons of it ?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I did not get your question completely, but try using below method from executor.
http://download.java.net/jdk7/archive/b123/docs/api/java/util/concurrent/Executors.html#newSingleThreadExecutor()


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implications of a singleton Thread