## Does Akka support communication with external threads

I have been developing with Orleans actor implementation. Recently, I saw that we were scheduling a long running job on an actor, which was effectively blocking the actor since it couldn’t process the next messages in its mailbox. Fortunately, Orleans provides a solution where a long running task can be scheduled on an external .Net thread and the actor is free to process next messages in the mailbox. Orleans also provides a way for the external .Net thread to send messages to actors. So, after the job was finished, we made the external .Net thread send required messages.

We were viewing this capability of Orleans as an actor being multithreaded. However, the actor model considers actors to be single threaded. Therefore, we were thinking about whether this multithreaded view of actors violates the actor model rules. When we asked this question on the Orleans forum, the response was `it is much better to view external tasks/threads, external services, etc. as external resources with side effects outside of the actor. Actors can call them and they can call actors, but that doesn't make these external resources part of the actor`.

Akka is another major implementation of actor model. Hence, I have following questions: –

1. Does Akka have any similar feature like Orleans where a long running task can be given to a separate thread while the actor proceeds onto the next message? I found something similar for Akka here, which is further explained here. These links talk about multiple threads in Akka, but I am not sure.
2. Does the `existence of external resources that can communicate with actors` or `actor with multiple threads` violate the principles of the actor model?

## Multithreaded parameterized programs with superexponential shared memory size in the number of threads?

In this question, a program means a parameterized multithreaded program with the interleaving semantics, a finite number of per-thread states (which may depend on the number of threads), and finite number of shared states (which may depend on the number of threads).

A shared state is a valuation of the shared memory, and a per-thread (in other terminology, local) state is the valuation of thread-local memory (we assume no stack). Interleaving semantics means that the actions of the threads are interleaved on a single processor and a thread has rw-access to the shared memory and its own local memory and no access to the local memories of the other threads. Parameterized means that we conside a family of programs generated from a finite-desciption template such that the $$n$$th member of the family has $$n$$ threads (which typically coincide up to the thread identifier).

To the best of my knowledge, for such a program, the size of the shared state-space is anywhere between constant (e.g., for a single boolean lock variable) and exponential (e.g., Peterson mutual exclusion protocol) in the number of the threads $$n$$.

Is there any well-known academic program in which the size of the shared state-space grows superexponentially in $$n$$?

## Problema com dois metodos e threads no java

Bom ao debugar meu codigo acabei descobrindo que estou com problemas nessas duas linhas de um metodo:

``    String sql = "SELECT login,senha FROM usuario where login = '" + jLogin.getText() + "' and  senha = '" + jSenha.getText() + "'";     conn.executeSQL(sql); ``

ou possívelmente problema no metodo executeSQL

``public void executeSQL(String sql) {     try {         statement = conexao.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);         resultset = statement.executeQuery(sql);     } catch (SQLException sqlex) {         System.out.println("Não foi possivel executar o comando: \n" + sqlex + "\n o sql passado foi: \n" + sql);     } } ``

minha class onde se encontra o metodo EXECUTESQL: p

``ublic class ConnectionFactory {      private static final String DRIVER = "com.mysql.jdbc.Driver";     private static final String URL = "jdbc:mysql://localhost:3306/helpsemeq"+"?verifyServerCertificate=false&useSSL=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=America/Sao_Paulo";     private static final String USER = "root";     private static final String PASS = "";     private static Connection conexao;     public Statement statement;     public ResultSet resultset;      public boolean getConnection() {         boolean result = true;         try {             Class.forName(DRIVER);             conexao = DriverManager.getConnection(URL, USER, PASS);             result = true;         } catch (ClassNotFoundException | SQLException ex) {             result = false;             throw new RuntimeException("Erro na conexão: ", ex);         }         return result;     }      public static void closeConnection(Connection con) {         try {             if (con != null) {                 con.close();             }         } catch (SQLException ex) {             Logger.getLogger(ConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);         }     }      public static void closeConnection(Connection con, PreparedStatement stmt) {         closeConnection(con);         try {             if (stmt != null) {                 stmt.close();             }         } catch (SQLException ex) {             Logger.getLogger(ConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);         }     }      public static void closeConnection(Connection con, PreparedStatement stmt, ResultSet rs) {         closeConnection(con, stmt);         try {             if (rs != null) {                 rs.close();             }         } catch (SQLException ex) {             Logger.getLogger(ConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);         }     }      public void executeSQL(String sql) {         try {             statement = conexao.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);             resultset = statement.executeQuery(sql);         } catch (SQLException sqlex) {             System.out.println("Não foi possivel executar o comando: \n" + sqlex + "\n o sql passado foi: \n" + sql);         }     } } ``

não sei se isso está relacionado a threads ou é algum problema no codigo

os erros ao compilar:

``Caused by: java.lang.reflect.InvocationTargetException Caused by: java.lang.NullPointerException ``

se tiver como alguém me dar uma luz pff.

I’ve just discovered Threads on Twitter and found that they could be a great way of keeping a daily feed of events related to one thing, but there are a problems, and I was wondering if there was a practical solution to them.

So lets say you’re doing a daily `24 Hours In The Life of Garden Birds` for a month. Ideally your first tweet would be an intorduction, and then the rest would be a summary of each hour. Followers would get an easy to read, hour by hour summary posted in time order.

The problem is, non followers who visit your profile see a long list of 25 individual tweets, posted in reverse order with the introduction last – Making your timeline look a bit crap to outsiders.

I figured a practical solution may be to have 2 accounts:

`@24HoursOfBirds` – A secondary account for posting the threads.

`@Birds` – The main account for retweeting the first tweet of each thread + important tweets that are not seen in thread format.

The problem of course is that all of your engagements are going to be made on the Secondary (`@24HoursOfBirds`) account, and you’re likely to make all of your followers in this account too.

Is there a way to make threads appear a little bit more asthetically pleasing to visitors to your profile?

I am pretty new to Trello and am wondering whether it is possible to improve the looks of the comments under a card. Out of the box, they all run in one thread, which makes it difficult to read, especially once the number of comments grows. It would be neat if one could have threads by replying to specific comments. I have looked through the Improvements (add-ons) section inside Trello, but have not found anything.

How can this be accomplished?

## maximum threads in asmx web service

In created on purpose an infinite loop and i realised that when i invoke an web service (asmx) i get a maximun of 6 inserts in a test table despite how many times i invoke the service any ideas why? (Hardware Intel® Core™ i3-7100 Processor)

``   [WebMethod]     public string DoTest()     {         if (Debugger.IsAttached)             System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");         int noPendingCalls = -1;          string jobID = generateID();         string startTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");           //Insert into VRP_POOL         do         {             string connectionString = "Data Source = *****; Initial Catalog = *****; User ID = ***; Password = ****";             string sql = " insert into VRP_Pool (jobID, Processed, Pending, Started) values( '" + jobID + "', 0, 1,'" + startTime + "')";             using (SqlConnection sql_conn = new SqlConnection(connectionString))             {                 sql_conn.Open();                 using (SqlCommand comm = new SqlCommand(sql, sql_conn))                 {                     comm.CommandType = CommandType.Text;                     comm.CommandTimeout = 600;                     comm.ExecuteNonQuery();                     System.Threading.Thread.Sleep(50000000);                 }             }         }         while (noPendingCalls != 0); ``

## 2 clients in 1 Server With Threads

In distributed sistems class, we’re making threads and sockets, the next project has the objective of having one server, which code is a little further, and have two clients that will connect to that client.

We’re not able to make the process of the two clients at the same time, it only processs what’s required from first client to connect, and when the process is done, the other client can’t continue with its own.

What can we change, or add to our code, so it is possible to make the two connections and process separatel?

This is the server

``public class Servidor { public static void main(String args[]) {     ServerSocket ss;      try      {         ss = new ServerSocket(4444);         Socket s1 = ss.accept();         conexiones con;         con = new conexiones(s1);         Thread hilo=new Thread(con);         hilo.start();     }      catch (IOException ex)      {         Logger.getLogger(Servidor.class.getName()).log(Level.SEVERE,null, ex);     } }}  class conexiones extends Thread{  Socket cliente; InputStream is; OutputStream os1; DataInputStream dis; DataOutputStream dos1;  conexiones(Socket c) {     this.cliente = c; }  public void run() {     int x,y,factorial=1;     int resultado = 0,resultado2[]=new int[10];     String a,b,c, tipo;       try      {        is = cliente.getInputStream();        os1 = cliente.getOutputStream();        dis = new DataInputStream(is);        dos1 = new DataOutputStream(os1);           do         {             System.out.println("Esperando el tipo de operacion...");             tipo = dis.readUTF();             System.out.println("La operacion seleccionada es :" + tipo);              if(tipo.equals("1"))             {                  a = dis.readUTF();                 System.out.println("El numero para sacar el factorial es "+a);                  x=Integer.parseInt(a);                 for (int i=x;i>0;i--)                  {                     factorial=factorial*i;                 }                  resultado=factorial;                  System.out.println("El resultado es: " + resultado);                 dos1.writeUTF(Integer.toString(resultado));             }             else if(tipo.equals("2"))             {                 a = dis.readUTF();                 System.out.println("Se seleccionaron "+a+" Para el fibonacci");                  x=Integer.parseInt(a);                 int secu=1;                 int secu2=1;                 int fibo[]=new int[10];                   fibo[1]=1;                 for (int i=2;i<=x;i++)                  {                     fibo[i]=secu2;                      secu2=secu+secu2;                     secu=secu2-secu;                 }                  resultado2=fibo;                  System.out.println("El resultado es: " +Arrays.toString(fibo));                 dos1.writeUTF(Arrays.toString(resultado2));             }             else if(tipo.equals("3"))             {                 a = dis.readUTF();                 System.out.println("Se selecciono "+a+" como el numero minimo de la serie");                  b = dis.readUTF();                 System.out.println("Se selecciono "+b+" como el numero maximo de la serie");                  x=Integer.parseInt(a);                 y=Integer.parseInt(b);                  int serie[]=new int [10];                 int j=0;                  for(int i=x;i<=y;i++)                 {                     serie[j]=i;                     j++;                 }                  resultado2=serie;                  System.out.println("El resultado es: " +Arrays.toString(serie));                 dos1.writeUTF(Arrays.toString(resultado2));             }             else if(tipo.equals("4"))             {                 System.out.println("Salio");                 dos1.writeUTF("Salio");             }         }while(!tipo.contains("4"));      }      catch (IOException ex)      {         Logger.getLogger(Servidor.class.getName()).log(Level.SEVERE, null, ex);     } } ``

}

this is the client

``public class Cliente2 extends Thread{ public static void main(String args[]) {     try {         String cad1,cad2,cad3;         String resultado = "";         Socket sc1 = new Socket("127.0.1.1",4444);         InputStreamReader isr = new InputStreamReader( System.in );         InputStream is = sc1.getInputStream();         BufferedReader bf = new BufferedReader(isr);         OutputStream os1 = sc1.getOutputStream();         DataOutputStream dos1 = new DataOutputStream(os1);         DataInputStream dis = new DataInputStream(is);          do         {             System.out.println("Que tipo de operacion quieres");             System.out.println("1)Factorial 2)Fibonacci 3)Serie 4)Salir");              cad3 = bf.readLine();             dos1.writeUTF(cad3);              if(cad3.contains("1"))             {                 System.out.println("Dame un numero para el factorial: ");                 cad1 = bf.readLine();                 dos1.writeUTF(cad1);                  resultado = dis.readUTF();                 System.out.println("El resultado es: " + resultado);             }             else if(cad3.contains("2"))             {                 System.out.println("Cuantos dijitos de fibonacci quiere ver? ");                 cad1 = bf.readLine();                 dos1.writeUTF(cad1);                  resultado = dis.readUTF();                 System.out.println("El resultado es: " + resultado);             }             else if(cad3.contains("3"))             {                 System.out.println("Ingrese el numero minimo de la serie");                 cad1 = bf.readLine();                 dos1.writeUTF(cad1);                  System.out.println("Ingrese el numero maximo de la serie");                 cad2 = bf.readLine();                 dos1.writeUTF(cad2);                  resultado = dis.readUTF();                 System.out.println("El resultado es: " + resultado);             }             else if(cad3.contains("4"))             {                 resultado = dis.readUTF();                 System.out.println(resultado);             }          }while(!cad3.contains("4"));         sc1.close();     } catch (IOException ex) {         Logger.getLogger(Cliente2.class.getName()).log(Level.SEVERE, null, ex);     }  }     ``

}