aspose file tools
The moose likes Threads and Synchronization and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Chris Roberts
Greenhorn

Joined: Sep 03, 2004
Posts: 8
I was trying to run three threads at the same time. The threads are called Bubble Sort, Selection Sort, and Insertion Sort. I have created at vector that is suppossed to create random numbers(it does) and a DisplayPanel that is supposed to display the sorted threads in my created frame. I kept getting an error at run time saying " Exception in thread "Thread-2" java.lang.NullPointerException at Sort$BubbleSort.run(sort.java:193). I don't know whats going on can someone help. Here is my code only for my display panel and BubbleSort() method for reference.

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24045
    
  13

Well, the only thing in BubbleSort.run() that could be null would be the array variable "a". It looks like you grab that from the enclosing class -- I don't see where the array is declared or initialized, though. So look at your code, and make sure that "a" is getting set to non-null at some point before you start the BubbleSort thread.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: Threads
 
Similar Threads
Drawing graphs
JFormattedTextField
Drawing in Graphic-Context of a JPanel in a JPanel
dynamic Drawing -->Vector ?
GeneralPath don't works