Relative Content

Tag Archive for javamultithreading

Thread.join throwing null pointer exception

I am using threading in my code and initializing it inside a while loop.
it executed successfully for 31 iterations, however after that for 5 remaining iterations it throws null pointer exception.

Thread suspending and resuming

I hope getting helped, because I have been trying to understand this program for 3 days. The essence of the program is the implementation of methods for pausing, resuming and stopping the flow. Code taken from Herbert Schildt’s Beginner’s Book, 9th Edition. Chapter 12. I didn’t write it exactly, but I think the essence is clear.

Thread stops after main function returns

I couldn’t find the right answer for my question.
I have a webservice that create an object and return its ID to a user but I would like to do another thing after the return statement.
I have used a new thread but due to that my function takes time, at first return statement is called, as a result the new thread (firstThread) never finishes! I appreciate any advice.
I don’t want to use join() for my thread because it will stop user from getting result from webservice until my job is done!
here are sample code: