Tags » Multi-threaded

Puzzle Solved! Politician Name Swap

The Challenge

The challenge comes from listener Steve Daubenspeck of Fleetwood, Pa. Take the first names of two politicians in the news. Switch the first letters of their names and read the result backward to name something that each of these politicians is not.

1,653 more words
Puzzle Solving!

Multi-Process Multi-Threaded Architecture in Oracle 12c

Overview

In default Unix/Linux architecture, every Oracle process including background and foregroundĀ onesĀ runs as a dedicated OS process.

In 12c release 1 ( 12.1.0.x ) multi-process multi-threaded architecture, those four background processes ( PMON, DBW, VKTM and PSP) run as dedicated OS processes, the rest processes can be configured running as a thread, which largely saves CPU and Memory usage. 2,268 more words

12c New Features

Logoff RDP sessions on multiple servers

Last year I got a request from a colleague to make a script which can logoff all users (remote desktop sessions) from all windows servers in our environment. 2,254 more words

Powershell

Java TCP Server and Handling Thread

When a TCP connection is received by the server, it is offloaded to a separate thread for the processing and interaction to occur.

public class LogTCPThread extends Thread {

    protected ServerSocket socket = null;
    protected boolean listen = true;
    int count = 0;
    
    public LogTCPThread() throws IOException {
        this("TCPThread");
    }

    public LogTCPThread(String name) throws IOException {
        super(name);
        socket = new ServerSocket(4446);
    }

    @Override
    public void run() {
        try {
            while (listen) {
                try {
                    // Wait for a syn handshake to open a connection
                    Socket connectionSocket = socket.accept();
                    System.out.println("Recieving: " + ++count);
                    // Thread out the rest of the connection
                    ProcessTCPThread processThread = new ProcessTCPThread(connectionSocket);
                    processThread.start();
                    
                } catch (Exception e) {
                    e.printStackTrace();
                    listen = false;
                }
            }
        } finally {
            try {
                socket.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}


public class ProcessTCPThread extends Thread {
    
     Socket connectionSocket;    
     public ProcessTCPThread(Socket connectionSocket) {
         this.connectionSocket = connectionSocket;
     }
    
     @Override
     public void run() {
         try {
             BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
             //DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
             String tcpData = inFromClient.readLine();
             //System.out.println("Received: " + tcpData);
             
             //outToClient.writeBytes("output);
             // figure out response
             RawLog log = new RawLog();
             log.dataString = tcpData;
             log.timestamp = new Date();
             log.sourceAddress = connectionSocket.getInetAddress().getHostAddress();
             log.sourceName = connectionSocket.getInetAddress().getHostName();
             log.sourceType = "TCP";

             Main.messagesToLog.add(log);
         } catch(Exception ex) {
             ex.printStackTrace();
         } finally {
            try {
                connectionSocket.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
         }
     }
}
Java

SQL CLR Multi-Threaded File Copy

I created a CLR C# Stored Procedure to Copy, Move and/or Delete files directly from T-SQL. This Procedure lets you pass in large sets of files, Queues them up, and processes them in parallel with an adjustable parallel thread pool size. 2,822 more words

C#

InvokeAction - a simple and convenient extension to Control for multi-threaded apps

Here’s a little extension method that makes for nice and simple coding when working with multi-threaded winform applications.

	public static class ControlExtensions
	{
		/// <summary>
		/// Calls Invoke on the control if it is required - use this in multi-threaded situations
		/// </summary>
		public static void InvokeAction<T>(this T control, Action<T> action) where T : Control
		{
			if (control.InvokeRequired)
			{
				try
				{
					control.Invoke
					(
						new Action<T, Action<T>>(InvokeAction),
						new object[] { control, action }
					);
				}
				catch (ObjectDisposedException)
				{
				}
			}
			else
			{
				action(control);
			}
		}
	}
… 83 more words
C#

Oracle 12c: where have all the processes gone ... ?

Multi-Process Multi-Threaded Oracle

If you are running Oracle databases on Unix or Linux you probably know that there are many processes even if no user is connected. 643 more words

Oracle