• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

thread creation and destruction

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was working on a packet capture program am trying to capture and stop a packet capture.I am using java threads to create a thread for capture and the java JButton to stop the capture but when i recapture packets i get a Thread exception saying i have already created the thread capture but i had already "killed" interrupted the thread when i pressed stop.I know thread stop,wait etc are obsolete but i don't know where how to stop a thread. here is the code


how do i stop threads or better how can i press stop to halt a capture thread then resume it when i press capture again.
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very long code, can't read it but generally once thread is stop then you can't start same thread again. New thread should be created. You can use wait/notify mechanism to inform the thread.
 
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Thread#stop is not obsolete. It is worse: irreparably broken and it must not be used. You should also not use threads in Swing, because Swing components are not thread‑safe. Find out about worker threads; I think that will help.
 
Micheal Harris
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice forum you guys have here
sorry for the long code.....i will have a look at the links and thanks for the first reply really helped.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic