I am creating many xml files and used thread class to create all the pages simultaneously but I am getting sax parser exception, so that pages are not created with required data. I am adding sample code here.
class PageThread extends Thread
public createPageThread(Content content)
this.content = content;
public void run()
This creatPage(Content) method has many methods.
I think when more than one thread try to access the same method that time we will get this error but I am not sure, If this is the case then what is the point of using threads?
Without the exception message and stack trace and the relevant code it's not possible to say what is going wrong.
If this is the case then what is the point of using threads?
The use of threads is often misunderstood and misapplied. If you want to parse 5 files, doing the task on 5 threads probably won't make it any faster and can even make it slower. Multi-threading tasks like this only helps if the processor is the bottle neck and you have multiple processors. If the bottleneck is reading from disk etc multiple threads will not help.
Where multiple threads help is when you have a time consuming task to perform but you don't want that task to stop other operations from working for example when you save a large file to disk if you don't want the GUI to freeze during the save operation you do the save on a separate thread.