In the case of an IM client. I created 2 separate threads for processing packets (via std io) and receiving packets. The question is how to make these two threads at the same time, so that I can continue to request input and at the same time be ready to receive packets at any time?
I already tried to set a timer, but the data is always lost.
I think you might have missed something important with threads, threads, or both :-)
You can start a new thread as follows:
myThread.start ();
The thread starts and the run () method will execute automatically with jvm.
- , , - .
. , :
Thread thread1 = new Thread () { public void run () { // ... your code here } }; Thread thread2 = new Thread () { public void run () { // ... your code here } }; thread1.start(); thread2.start();
, , , . , , , .
I/O, , , , . , ?
Source: https://habr.com/ru/post/1706742/More articles:How to pass a variable to a function created using the manual - matlabHow to optimize this ruby code bit to go faster? - optimizationWhat is the difference between Indy 9 and Indy 10? - delphiWhat other IoC containers have an IInitializable similar feature? - dependency-injectionhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1706741/can-i-sync-mobile-desktop-and-web-server-databases-with-sync-framework&usg=ALkJrhjta8_7Nk656qhbtJ0Jo7ZTRNOmmAHow to use structures within a class correctly? - c ++Visual Studio 2008 works with only one web application, not a solution - visual-studio-2008Вывод команды dump php в файл - phpSqlDataAdapter.Fill () Timeout - Sproc base returns quickly - sqlHttp Library in C # - httpAll Articles