|
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.text.JTextComponent.getSelectionStart(Unknown Source) at javax.swing.text.PlainView.paint(Unknown Source) at javax.swing.plaf.basic.BasicTextUI$RootView.paint(Unknown Source) at javax.swing.plaf.basic.BasicTextUI.paintSafely(Unknown Source) at javax.swing.plaf.basic.BasicTextUI.paint(Unknown Source) at javax.swing.plaf.basic.BasicTextUI.update(Unknown Source) at javax.swing.JComponent.paintComponent(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source) at javax.swing.JComponent.paintDoubleBuffered(Unknown Source) at javax.swing.JComponent._paintImmediately(Unknown Source) at javax.swing.JComponent.paintImmediately(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown ... |
I'm trying just to do the example shown on the : http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html. That all, and in fact my class was extending the Thread class but when I started to redefine the method stop, there was an error telling me that it is not possible to redefine the final method stop() of the class Thread. So I asked my self, is the ... |
|
|
Well, I guess you could make a boolean, and if it is false, implying that the programmer ran start() before doing the variables, throw a new exception. Or, since you have to functions, you could make it an int that goes up by one every time one of the setup functions is called, and if it is less than 2 when ... |
Thread.stop has been depracated as unsafe. The legitimate way for a thread to stop is for it to return from the run() method. Typically you do this by interrupting the thread. If the thread is in sleep or wait this will trigger an InterruptedException. If not, it sets a flag, which the thread should check when it does a loop. (If ... |
|
|
Hello, I create a threadGroup and add few thread, I can start all thread in the threadGroup this is correct. I add thread.class in the threadstop boolean variable if it is false the thread is stopping. When i start the thread in threadGroup i put the thread Object in the Arraylist because i think get a thread object in the arraylist ... |
The scheduler thread is set to priority 4. The behavior that I WANT is for the scheduler to run every 10 milliseconds (as controlled by the sleep(10) line in the scheduler) and to have the appropriate other thread run in the intervening period. Since the Scheduler thread is always a higher priority I would think that it should run when it ... |
|
|
First of all, MyThread isn't a Thread. It is a Runnable. No, I'm not saying you should make it extend Thread either. I'm just saying it isn't a thread. If you want your constructor to start a thread, you can do that but it wouldn't necessarily be advised. MyThread() { new Thread(this).start(); } It's not a good idea to pass "this" ... |
|
A thread can only be run once. You will need to create and start a new instance in your actionPerformed() method. If you make class someThread implement Runnable rather than extend Thread then you can re-use the same instance as the argument to a new Thread created and started in the actionPerformed() method. |
Hello togehter! I have an application. The GUI has 2 buttons and there is one class behind. I am reading from a com port. The one button starts the reading and the other one should stop it. But when I started the reading the thread is busy, so my question: What is the easiest way to make 2 threads out of ... |
I've searched through the forums for some direction on this but have been unsuccessful in finding anything I could use yet. What I am trying to accomplish is the following: 1. I have a multithreaded application 2. User can enter login information and then initiate the login thread by clicking the login button 3. Login button turns into a Cancel button ... |
It might not solve his fundamental problem, but it sure will fix the horrible piece of code he has there. He's calling invokeLater and then busy waiting for the event to be processed (at least according to the code he's showing). Since he's doing busy waiting, he might as well switch to non-busy waiting and use invokeAndWait(). |